如果您使用的是最大化窗口,則可以在舞臺上偵聽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