Call: (209) 560-6611

How to find the screen size of the device using AS3

Date: August 12, 2014 Author: ang Category: Tutorials Tags: , , Comments: 0

The code below will display the size of the current device screen that the SWF is run on. This also works as an AIR application. In order for this code to work, you will need to create a text field on the stage with the instance name of 'sizeTxt'. Also make sure the Text field is set to 'Dynamic Text'. Insert the code below on frame 1 of the flash project's timeline.

 Javascript |  copy code |? 
1
2
import flash.system.Capabilities;
3
 
4
var screenWidth:Number = Capabilities.screenResolutionX;
5
var screenHeight:Number = Capabilities.screenResolutionY;
6
 
7
	sizeTxt.text = ("sw2:"+screenWidth+" sH2:"+screenHeight);

Leave a Reply

Your email address will not be published. Required fields are marked *

Before you post, please prove you are sentient.

what is 2 plus 4?

Before you post, please prove you are sentient.

What is the outer covering of a tree?