I have been going crazy over this! I have an Air (2.6) app which, when running opens up a pop up NativeWindow, to handle alerts.
public var _alertWindow:NativeWindow;
_alertWindow = new NativeWindow(windowOptions);
_alertWindow.stage.scaleMode = StageScaleMode.NO_SCALE;
_alertWindow.stage.align = StageAlign.TOP_LEFT;
_alertWindow.bounds = new Rectangle(0, 0, content.width, content.height);
_alertWindow.title = "";
_alertWindow.alwaysInFront = true;
_alertWindow.x = Screen.mainScreen.bounds.width - _containerWidth;
_alertWindow.y = Screen.mainScreen.bounds.height - _containerHeight;
_alertWindow.stage.addChild(_contentContainer);
This all works great - when closing the app via a close button I call:
AppName._alert._alertWindow.close();
NativeApplication.nativeApplication.exit();
I have had no problems with this across all platforms. But in Windows7, when right click on the taskbar and selecting 'close-window' only closes the main app and not its child NativeWindow. ( This keeps the app running in the background - so when a user tries to access it again it does't run ) I have tried adding event listeners like Event.CLOSING, and various other methods but have failed. If anyone has any ideas on how to close windows from the 'close window' option in windows7.
Thanks for your help
Jono
You can close all native windows that are open using something simillar to this:
private function closeMenus() : void
{
var nativeWindows:Array = NativeApplication.nativeApplication.openedWindows;
for ( var i:int = 0; i< nativeWindows.length; i++)
{
if(!(nativeWindows[i] as NativeWindow).closed)
{
(nativeWindows[i] as NativeWindow).close();
}
}
}
Presuming you have a handler somewhere that calls exit:
NativeApplication.nativeApplication.exit();
You can place this code before this call.