AIR 1.1 – Maximized Window at Startup
November 16th, 2008 • AIR, ActionScript
There are a lot of settings for the initial window in the application descriptor file but none for getting a maximized window at startup. To achieve that you have to call stage.nativeWindow.maximize() in your Document Class. This works fine but you’ll actually see the small window being maximized and this isn’t very cool. To avoid this you can set visible = false for the initial window in the descriptor file and show the window after maximizing it but take into account that the maximize() method is asynchronous and therefore setting stage.nativeWindow.visible = true right after the call won’t change anything. Use the NativeWindowBoundsEvent.RESIZE event to determine when your window size has changed.
... public function Main() { stage.nativeWindow.addEventListener(NativeWindowBoundsEvent.RESIZE, resize); stage.nativeWindow.maximize(); } private function resize(event : NativeWindowBoundsEvent) : void { // show window + set keyboard and mouse focus stage.nativeWindow.activate(); } ...
Apparently this works on OSX but not on Windows. There the window has to be visible in order to maximize it. I didn’t do many tests so prove me wrong if you have other experiences.