1. Computing

Using System.capabilities to Determine a User's Screen Size


Right-click on the controller clip and select Actions to open the Actions panel. We're going to use an onClipEvent (enterFrame) to check the width and height of the screen as the movie clip cycles through its single frame:
 onClipEvent (enterFrame) { 
xres = System.capabilities.screenResolutionX; 
yres = System.capabilities.screenResolutionY; 

You'll notice that there are two functions, assigned to two variables: xres and yres. Flash doesn't actually get the resolution as one value, but instead as two separate values. Let's break down how:

System.capabilities.screenResolutionX: This fetches the width value of the user's screen resolution in pixels. This is a static value that you can't affect; you cannot change the user's resolution, but you can change things in your movie based on the resolution by assigning the value to a variable and using it in various scripts.

System.capabilities.screenResolutionY: This fetches the height value of the user's screen resolution in pixels. Again, you can't change the value itself, but you can assign it to a variable to change various things in your movie.

©2014 About.com. All rights reserved.