AIR NativeWindow 窗口控制
几个重点:
1、AIR默认会生成一个主窗口,可以用this.stage.nativeWindow获得对主窗口的引用;
2、AIR程序可生成多个窗口,并使用addChild向窗口添加内容;
3、窗口colse后就不能在重新打开了,只能从新构造窗口,或者使用visible方式是窗口暂时不显示;
4、主窗口的初始设置是在app.xml文件里完成的,新建窗口要使用NativeWindowInitOptions进行窗口初始化设置
代码如下:
下载: window.as
- package {
- import flash.display.MovieClip;
- import flash.display.NativeWindow;
- import flash.display.NativeWindowInitOptions;
- import flash.display.NativeWindowType;
- import flash.events.MouseEvent;
- public class testWindow extends MovieClip {
- private var myBox1:MovieClip;
- private var myBox2:MovieClip;
- private var mainWin:NativeWindow;
- private var window:NativeWindow;
- public function testWindow() {
- myBox1 = new box();
- myBox2 = new box();
- mainWin = stage.nativeWindow;
- with (myBox1) {
- x=100;
- y=100;
- alpha=.5;
- }
- with (myBox2) {
- x=400;
- y=100;
- //alpha=.5;
- }
- mainWin.stage.addChild(myBox1);
- mainWin.stage.addChild(myBox2);
- myBox1.addEventListener(MouseEvent.CLICK,clickHandler1);
- myBox2.addEventListener(MouseEvent.CLICK,clickHandler2);
- }
- private function clickHandler1(event:MouseEvent):void {
- var options:NativeWindowInitOptions = new NativeWindowInitOptions();
- options.type = NativeWindowType.UTILITY;
- if (!window||window.closed) {
- window = new NativeWindow(options);
- window.width = 200;
- window.height = 200;
- window.activate();
- }
- }
- private function clickHandler2(event:MouseEvent):void {
- if (!window.closed) {
- window.width += 100;
- window.height += 100;
- }
- }
- }
- }
2 Responses to “AIR NativeWindow 窗口控制”
Leave a Reply


Nadine on 四月 28th, 2009
Hi,
Can i take a one small picture from your blog?
Nadine
Army Spank on 十二月 26th, 2009
nice site platform