Thursday, October 20, 2011

How to know display settings for the device using actionscript

You should use the flash.system.Capabilities object to determine the display settings of the device that is playing the movie. The screenResolutionX and screenResolutionY properties return the display resolution in pixels.
// Example output: // 1024 // 768 trace(flash.system.Capabilities.screenResolutionX); trace(flash.system.Capabilities.screenResolutionY);
If you want to load different swf file in mobile and other small resolution devices you can use the following method.
var resX:int = flash.system.Capabilities.screenResolutionX; var resY:int = flash.system.Capabilities.screenResolutionY; if ( (resX <= 240) && (resY <= 320) ) { var url:String = "main_mobile.swf"; } else { var url:String = "main_desktop.swf"; } loader.load(new URLRequest(url));

0 comments: