今天说一下AIR中的window, 作为桌面应用,免不了会有多窗口存在的可能。所以这也是AIR于Flex web的另一区别。flex web应用的“窗口”都是内部窗口,不管你怎么拖拽它也不会超出flash player的范围。而我们今天说的air中的窗口,是没有范围限制的,任一窗口都可以说是一个“独立”的存在,不受主程序窗口的限制。
Demo主要有以下功能
1. 简单继承window类创建MyWindow。加入parentWindow属性以及advOpen()方法, 设置MyWindow默认样式。
2. 从主程序中弹出窗口1,从窗口1中弹出窗口2。每个窗口里有image和button
3. 窗口1可以关闭主程序窗口,窗口2可以关闭窗口1。(关闭父窗口)
1. 简单继承window类创建MyWindow。加入parentWindow属性以及advOpen()方法, 设置MyWindow默认样式。
下面是我继承于WIndow的MyWindow,构造方法中设置了默认样式,parentWindow用于在打开窗口时保存父窗口对象。
public class MyWindow extends Window
{
public var parentWindow:Object;
public function MyWindow()
{
this.systemChrome = “none”; //不显示系统窗口
this.showStatusBar = false; //不显示底部状态栏
this.showGripper = false; //不显示底部大小控制按钮
}
/**
* 自定义open()打开窗口并且保存调用此方法的对象
*/
public function advOpen(parentWindow:Object,openWindowActive:Boolean = true):void{
this.parentWindow = parentWindow;
this.open(true)
}
}
2. 从主程序中弹出窗口1,从窗口1中弹出窗口2。每个窗口里有image和button
3. 窗口1可以关闭主程序窗口,窗口2可以关闭窗口1。(关闭父窗口)
下面是窗口1类,继承于MyWindow。在主程序中用了与下面相同的openWin打开窗口1,可以看倒在调用winX.advOpen时传入了当前对象作为被打开窗口的parentWindow. 下面的closeParent()中利用保存的 parentWindow关闭父窗口。
<local:MyWindow xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” width=”435″ height=”320″ xmlns:local=”*”>
<mx:Script>
<![CDATA[
import mx.core.Window;
//打开窗口2
private function openWin():void{
var win2:PicTwo = new PicTwo();
win2.advOpen(this);
win2.move(500,50)
}
//关闭父窗口
private function closeParent():void{
if(this.parentWindow.hasOwnProperty("close")){ //检查父窗口中是否有close方法。
this.parentWindow.close(); //调用父窗口的close方法
}
}
]]>
</mx:Script>
<mx:Canvas>
<mx:Image source=”@Embed(‘images/2.png’)” />
<mx:Button label=”打开我的表情2″ click=”openWin()” x=”325″ y=”174″/>
<mx:Button label=”关闭父窗口” click=”closeParent()” x=”342″ y=”204″/>
</mx:Canvas>
</local:MyWindow>
主程序
<mx:WindowedApplication showStatusBar=”false” showGripper=”false” xmlns:mx=”http://www.adobe.com/2006/mxml” width=”430″ height=”328″ layout=”absolute”>
<mx:Script>
<![CDATA[
import mx.core.Window;
private function openWin():void{
//新建window对象
var win:PicOne = new PicOne();
win.advOpen(this); //弹出窗口
win.move(50,50);
}
]]>
</mx:Script>
<mx:Canvas>
<mx:Image source=”@Embed(‘images/1.png’)” />
<mx:Button label=”打开我的表情1″ click=”openWin()” x=”325″ y=”174″/>
</mx:Canvas>
</mx:WindowedApplication>


sd
Reply
正是我想要的
Reply
Louis Vuitton
Gucci Shoes
Hermes Handbags
christian louboutin
nike shoes
replica bags
Louis Vuitton
Gucci Bags
Cheap gucci shoes
wholesale gucci shoes
louis vuitton
herve leger
Rolex Watches
Omega Watches
louis vuitton multicolore
louis vuitton vernis
louis vuitton multicolore
Reply
I will bookmark your blog and have my kids check up here frequently Air Jordan 2010. I’m very certain they will understand lots of new stuff Air jordan 1 here than anybody else. I do appreciate that youve added relevant and intelligent commentary here though. Thank you!
Reply