【问题标题】:Closing child nativeWindows when main app gets closed (via OS)当主应用程序关闭时关闭子 nativeWindows(通过操作系统)
【发布时间】:2012-03-14 23:00:11
【问题描述】:

我已经为此发疯了!我有一个 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 中的“关闭窗口”选项关闭窗口有任何想法。

感谢您的帮助

乔诺

【问题讨论】:

    标签: flash air desktop-application nativewindow


    【解决方案1】:

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

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

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

    【讨论】:

    • 是的! .openWindows 非常感谢!真的是在这个问题上束手无策!
    猜你喜欢
    • 2014-06-20
    • 2014-02-05
    • 2011-10-31
    • 1970-01-01
    • 2011-12-29
    • 2018-10-19
    • 2016-02-20
    • 1970-01-01
    • 2016-03-16
    相关资源
    最近更新 更多