5/29/2010 12:09:00 PM
Title:
How can I detect the user's screen resoultion in AS3 to make my stage and its contents the same size
Hi,
I want to detect the user's screen resolution in AS3 so that I can make my stage and its contents the same size dynamically?
Thank you,
Sachin
5/29/2010 11:15:30 PM
you can attach resize listener to stage. which will inform your flex application when the stage is resized.
first you need to set the height and width to 100% in the html for flash movie.
then use the following code inside flex.
//call this function on applicationComplete
private function setScaleMode():void{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, resizeEventHandler);
}
function resizeEventHandler(evt:Event) {
trace("Changed Width: "+stage.stageWidth);
trace("Changed Height: "+stage.stageHeight);
}
5/29/2010 11:29:25 PM
you can also zoom your swf according to the changed browser resolution, for that you can set the height/width to 100% in the embed and object tags of flash.
Set the scalemode property to showall, this will make your swf movie zoom inand out with cahnge in resolution/ screeen or browser size
stage.scaleMode= StageScaleMode.SHOW_ALL;
5/31/2010 9:54:20 PM
One can also find the screen resolution using Capabilities class..
Capabilities.screenResolutionX and Capabilities.screenResolutionY gives the resolution!!