简体   繁体   English

AS3 AIR-NativeWindow弹出框

[英]AS3 AIR - NativeWindow pop-up box

In my AIR application, when a user creates a new project I want a pop-up box to appear where they can enter their project's name in. I understand how this is doable by making my own type of pop-up box, but is there a way to do this using NativeWindows? 在我的AIR应用程序中,当用户创建一个新项目时,我希望在他们可以输入其项目名称的位置出现一个弹出框。我了解如何通过制作自己的弹出框类型来做到这一点,但是在那里一种使用NativeWindows的方法? That is, can I make a window using the system chrome appear which contains a text field and a button? 也就是说,我可以使用系统镶边使包含文本字段和按钮的窗口出现吗?

I'm using Flex 4 and AIR 2.7 in FlashDevelop. 我在FlashDevelop中使用Flex 4和AIR 2.7。

Yes you can. 是的你可以。 When creating a new NativeWindow you can add and remove children to its stage. 创建新的NativeWindow时,可以在其阶段添加和删除子级。 So you could add your class / components to the new window and listen to their events. 因此,您可以将您的类/组件添加到新窗口,并监听它们的事件。

// create NativeWindowInitOptions
var windowInitOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
windowInitOptions.type = NativeWindowType.NORMAL;
windowInitOptions.minimizable = true;
windowInitOptions.resizable = false;
windowInitOptions.maximizable = false;
windowInitOptions.systemChrome = NativeWindowSystemChrome.STANDARD;
windowInitOptions.transparent = false;

// create new NativeWindow
var newWindow:NativeWindow = new NativeWindow(windowInitOptions);

// create your class
var popupBox:Sprite = new Sprite();

// resize
newWindow.width = popupBox.width;
newWindow.height = popupBox.height;

// add
newWindow.stage.addChild(popupBox);

// configure
popupBox.addEventListener(YourCustomEvent.CONFIRM, onPopupConfirm);

// for a popup it might be nice to have it activated and on top
newWindow.alwaysInFront = true;
newWindow.activate();

Within the onPopupConfirm function you can close the Window and cleanup references. 在onPopupConfirm函数中,您可以关闭Window和清理引用。 (Event.CLOSING on the NativeWindow, could come in handy for catching alt+F4 closing and such) (NativeWindow上的Event.CLOSING可能对捕获alt + F4关闭等很有用)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM