0

我已经为此发疯了!我有一个 Air (2.6) 应用程序,它在运行时会弹出一个 NativeWindow 来处理警报。

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 中的“关闭窗口”选项关闭窗口有任何想法。

谢谢你的帮助

城野

4

1 回答 1

0

您可以使用与此类似的方法关闭所有打开的本机窗口:

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

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

于 2012-03-15T08:56:15.710 回答