如果您使用的是最大化窗口,则可以在舞台上侦听Event.RESIZE
(调整窗口大小时调度),或者侦听本机窗口displayStateChange
或resize
事件。
如果您使用的是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;
}
感谢BFAT!我正在尝试类似的事情,但没有得到任何事件。我会在你的实施中采取一些措施。这将永远达到电脑/屏幕设置的全部分辨率? –
它会,但是,很难确切知道你的确切情况会发生什么。是否使用FULL_SCREEN显示状态?或只是一个最大化的窗口? (您还可以听舞台的显示状态变化,以了解您何时从全屏幕启动,如果您使用全屏幕,则可能更可靠) – BadFeelingAboutThis
尝试此操作后请对您的结果进行评论。如果它不起作用,请在尝试重新最大化或重新全屏之前尝试在事件发生后添加几秒钟的延迟。 – BadFeelingAboutThis