• Home
  • About

Getting the screen dimensions for Air Windows.

Posted by flexnrosescom on October 2, 2009; This entry is filed under Flex.

I want just to make it easier to get the screen dimensions found under the screen. I used the code found here: http://cookbooks.adobe.com/index.cfm?event=showdetails&postId=10823

So i just created a class that is static, and gives me the rectangle dimensions just when i need it and saving me writing the code..

package com.juandevelops.air.utils
{
import flash.display.NativeWindow;
import flash.display.NativeWindowInitOptions;
import flash.display.NativeWindowSystemChrome;
import flash.display.StageDisplayState;
import flash.events.EventDispatcher;
import flash.geom.Rectangle;

public class ScreenUtils
{
public static function getScreenRectangle():Rectangle
{
//set the window options before creating the window…
var options:NativeWindowInitOptions = new NativeWindowInitOptions()
options.systemChrome=NativeWindowSystemChrome.NONE;
options.transparent=true;

var tmpWindow:NativeWindow = new NativeWindow( options );

//blow up the window to take up the full size of the monitor…
tmpWindow.stage.displayState = StageDisplayState.FULL_SCREEN;

var rect:Rectangle = tmpWindow.bounds.clone();

//get rid of invisible window
tmpWindow.close();

return rect;
}
}
}

so it will be easier to use ScreenUtils.getScreenRectangle() anywhere else.

Leave a Reply

Categories

  • Actionscript (19)
  • Android (3)
  • CSS (2)
  • Design Patterns (4)
  • Flex (18)
  • Geek (2)
  • Javascript (12)
  • PHP (3)
  • Wordpress (1)

RSS

  • RSS Blog
  • RSS Comments