Adobe AIR - 全屏/显示

时间:2016-07-15 18:34:33

标签: actionscript-3 flex air

运行AIR的Windows计算机。

每晚教育显示都会被关闭。电脑继续使用。

在某些显示屏上,当它们在早上开启时,屏幕分辨率会从1920 x 1080开始,然后再到1024 x 768,然后再回到1920 x 1080。

当由于某种原因发生这种情况时,AIR应用程序会突然出现并保持在1024 x 768,并且不会占据全屏,您可以看到桌面。我们必须手动重新启动AIR应用程序。

有没有办法在发生这种情况时我们可以检测并返回强制全屏?

提前感谢任何建议。

1 个答案:

答案 0 :(得分:3)

如果您使用的是最大化窗口,则可以在舞台上侦听Event.RESIZE(在调整窗口大小时调度),或者侦听本机窗口displayStateChangeresize事件。

如果您正在使用FULL_SCREEN(或FULL_SCREEN_INTERACTIVE)显示状态,则可以侦听FullScreenEvent.FULL_SCREEN事件,以了解该更改的时间。

以下是您可以尝试的一些示例:

//in your document class or main timeline, listen for the following events:

stage.nativeWindow.addEventListener(NativeWindowBoundsEvent.RESIZE, windowResized);
//the above will fire anytime the window size changes, Really this is all you need as this event will fire when the window display state changes as well.

stage.nativeWindow.addEventListener(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGE, windowResized);
//the above will fire anytime the window state changes - eg. Maximized/Restore/Minimize.  This likely won't trigger on a resolution change, but I've included it anyway

stage.addEventListener(FullScreenEvent.FULL_SCREEN, fullscreenChange);
//the above will fire whenever you enter or leave fullscreen mode (stage.displayState)
private function windowResized(e:Event):void {
    //re-maximize the window
    stage.nativeWindow.maximize();

    //OR Go to full screen mode
    stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
}

private function fullscreenChange(e:FullScreenEvent):void {
    if (!e.fullScreen) {
        //in half a second, go back to full screen
        flash.utils.setTimeout(goFullScreen, 500);
    }
}

private function goFullScreen():void {
    stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
}