2012-03-14 107 views
0

我一直在为此疯狂!我有Air(2.6)应用程序,它在运行时打开NativeWindow弹出窗口来处理警报。当主应用程序关闭时关闭child nativeWindows(通过操作系统)

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); 

这一切的伟大工程 - 通过一个关闭按钮,我呼吁关闭应用程序时:

AppName._alert._alertWindow.close(); 
    NativeApplication.nativeApplication.exit(); 

我曾与这在所有平台上没有任何问题。但在Windows7中,右键单击任务栏并选择“关闭窗口”仅关闭主应用程序,而不关闭其子NativeWindow。 (这使应用程序在后台运行 - 所以当用户试图再次访问它不会运行)我曾尝试添加事件监听器,如Event.CLOSING和其他各种方法,但都失败了。如果任何人有关于如何关闭windows7中'关闭窗口'选项的任何想法。

感谢您的帮助

城野

回答

0

您可以关闭所有的原生Windows中使用这个东西呈三角打开的:

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(); 
     } 
    } 
} 

假设你有一个处理的地方,调用exit:

NativeApplication.nativeApplication.exit(); 

您可以在此调用之前放置此代码。

+0

是的! .openWindows非常感谢你!认真地以这个结局而告终! – Jono 2012-03-15 21:51:53

相关问题