AIR - Determine the User's Screen SizeDecember 6th, 2008
Here's a trick that you can use to figure out the dimensions of the user's screen so that you can size and position your native window.You can make an invisible native window then maximize it and copy it's 'bounds' property (which is a Rectangle). Note that init() is called on creationComplete of the main mxml component (mx:WindowedApplication). Here's the code... private function init():void{ //set sceenRect to the dimensions of the monitor... screenRect = getScreenRect(); //stretch the app window to match the screen width... this.width = screenRect.width; this.height = 300; //align the app window to the left edge of the screen... nativeWindow.x = screenRect.x; //doc the app window to the bottom of the screen... nativeWindow.y = screenRect.height - this.height; } private function getScreenRect():Rectangle { //set the window options before creating the window... var options:NativeWindowInitOptions = new NativeWindowInitOptions() options.systemChrome=NativeWindowSystemChrome.NONE; options.transparent=true; //create invisible window so we can find the top of the taskbar var tmpWindow:NativeWindow = new NativeWindow(options); //blow up the window to take up the full size of the monitor... tmpWindow.maximize(); //copy the dimensions to var screenRect... var rect:Rectangle = tmpWindow.bounds.clone(); //get rid of invisible window tmpWindow.close(); return rect; }
|
![]() RECENT ARTICLES
|
