在我的AIR应用程序,当用户创建一个新的项目,我希望出现一个弹出框,他们可以进入他们的项目的名字。我明白这是可行的通过我自己的类型的弹出框,但有没有办法使用NativeWindows做到这一点?也就是说,我可以做一个窗口使用系统镶边出现,其中包含一个文本框和一个按钮?
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? That is, can I make a window using the system chrome appear which contains a text field and a button?
我在FlashDevelop中使用Flex 4和AIR 2.7。
I'm using Flex 4 and AIR 2.7 in FlashDevelop.
当然可以。创建新的NativeWindow时您可以添加和删除孩子的阶段。所以,你可以添加你的类/组件的新窗口,并听取他们的活动。
Yes you can. When creating a new NativeWindow you can add and remove children to its stage. 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();
在onPopupConfirm功能,您可以关闭该窗口,并清理参考。 (Event.CLOSING在NativeWindow中,可以派上用场追赶ALT + F4关闭和等)
Within the onPopupConfirm function you can close the Window and cleanup references. (Event.CLOSING on the NativeWindow, could come in handy for catching alt+F4 closing and such)