LATEST NEWS
NOTICE BOARD...!!!
Latest topics
ActionScript program for Detecting Display Settings
Page 1 of 1
ActionScript program for Detecting Display Settings
Record 8: Detecting Display Settings
---------------------------------------------------------------------------
Problem
You want to know the display settings for the device on which the movie is being played.
Solution
Use the screenResolutionX and screenResolutionY properties of the System.capabilities object.
Discussion
You should use the 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(System.capabilities.screenResolutionX);
trace(System.capabilities.screenResolutionY);
You can use these values to determine how to display a movie or even which movie to load. These decisions are increasingly important as more handheld devices support the Flash Player. For example, the dimensions of a cell phone screen and a typical desktop computer display are different, so you should load different content based on the playback device:
resX = System.capabilities.screenResolutionX;
resY = System.capabilities.screenResolutionY;
// If the resolution is 240 x 320 or less, then load the PocketPC movie version.
// Otherwise, assume the device is a desktop computer and load the regular content.
if ( (resX <= 240) && (resY <= 320) ) {
_root.loadMovie("main_pocketPC.swf");
}
else {
_root.loadMovie("main_desktop.swf");
}
You can also use the screen-resolution values to center a pop-up browser window:
resX = System.capabilities.screenResolutionX;
resY = System.capabilities.screenResolutionY;
// Set variables for the width and height of the new browser window.
winW = 200;
winH = 200;
// Determine the x and y values in order to center the window.
winX = (resX / 2) - (winW / 2);
winY = (resY / 2) - (winH / 2);
// Create the code that, when passed to getURL( ), opens the new browser window.
jsCode = "javascript:void(newWin=window.open('http://www.person13.com/'," +
"'newWindow', 'width=" + winW +
", height=" + winH + "," +
"left=" + winX + ",top=" + winY + "'));";
// Call the JavaScript function using getURL( ).
_root.getURL(jsCode);
Additionally, it is worth considering using the screen-resolution values to determine whether to scale a movie. For example, when users have their resolution set to a high value such as 1600 x 1200, some fonts may appear too small to read.
-------------------------------------------------------------------------
Program
---------------------------------------------------------------------------
var resX=System.capabilities.screenResolutionX;
var resY=System.capabilities.screenResolutionY;
var winw=200;
var winH=600;
var winX=(resX/2)-(winW/2);
var winY=(resY/2)-(winH/2);
var jscode="javaScript:void(newwin=window.open('http://www.yahoo.com',"+"'newwindow','width="+winW+",height="+winH+","+"left="+winX+",top="+winY+"'));";
_root.getURL(jscode);
---------------------------------------------------------------------------
Problem
You want to know the display settings for the device on which the movie is being played.
Solution
Use the screenResolutionX and screenResolutionY properties of the System.capabilities object.
Discussion
You should use the 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(System.capabilities.screenResolutionX);
trace(System.capabilities.screenResolutionY);
You can use these values to determine how to display a movie or even which movie to load. These decisions are increasingly important as more handheld devices support the Flash Player. For example, the dimensions of a cell phone screen and a typical desktop computer display are different, so you should load different content based on the playback device:
resX = System.capabilities.screenResolutionX;
resY = System.capabilities.screenResolutionY;
// If the resolution is 240 x 320 or less, then load the PocketPC movie version.
// Otherwise, assume the device is a desktop computer and load the regular content.
if ( (resX <= 240) && (resY <= 320) ) {
_root.loadMovie("main_pocketPC.swf");
}
else {
_root.loadMovie("main_desktop.swf");
}
You can also use the screen-resolution values to center a pop-up browser window:
resX = System.capabilities.screenResolutionX;
resY = System.capabilities.screenResolutionY;
// Set variables for the width and height of the new browser window.
winW = 200;
winH = 200;
// Determine the x and y values in order to center the window.
winX = (resX / 2) - (winW / 2);
winY = (resY / 2) - (winH / 2);
// Create the code that, when passed to getURL( ), opens the new browser window.
jsCode = "javascript:void(newWin=window.open('http://www.person13.com/'," +
"'newWindow', 'width=" + winW +
", height=" + winH + "," +
"left=" + winX + ",top=" + winY + "'));";
// Call the JavaScript function using getURL( ).
_root.getURL(jsCode);
Additionally, it is worth considering using the screen-resolution values to determine whether to scale a movie. For example, when users have their resolution set to a high value such as 1600 x 1200, some fonts may appear too small to read.
-------------------------------------------------------------------------
Program
---------------------------------------------------------------------------
var resX=System.capabilities.screenResolutionX;
var resY=System.capabilities.screenResolutionY;
var winw=200;
var winH=600;
var winX=(resX/2)-(winW/2);
var winY=(resY/2)-(winH/2);
var jscode="javaScript:void(newwin=window.open('http://www.yahoo.com',"+"'newwindow','width="+winW+",height="+winH+","+"left="+winX+",top="+winY+"'));";
_root.getURL(jscode);
Similar topics
» ActionScript program for Detecting the player version
» ActionScript program for Detecting the Operating System
» ActionScript program for Binary Search
» ActionScript program for Drawing a Circle
» ActionScript program for Scripting Mask
» ActionScript program for Detecting the Operating System
» ActionScript program for Binary Search
» ActionScript program for Drawing a Circle
» ActionScript program for Scripting Mask
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Mon Sep 14, 2009 12:07 pm by NIETGALAXY
» Bollywood actresses In Sarees
Mon Sep 14, 2009 12:05 pm by NIETGALAXY
» Childhood photos of Bollywood stars
Mon Sep 14, 2009 12:02 pm by NIETGALAXY
» How to Use the Secret
Sat Sep 05, 2009 1:35 pm by NIETGALAXY
» How to Be A Teacher's Pet
Sat Sep 05, 2009 1:28 pm by NIETGALAXY
» How to Get into the Habit of Studying for a Test
Sat Sep 05, 2009 1:24 pm by NIETGALAXY
» Vodafone Free GPRS hack
Tue Aug 18, 2009 8:31 pm by anil kumar
» How To Get Big Arms?
Tue Aug 18, 2009 8:24 pm by anil kumar
» Airtel GPRS hack
Tue Aug 18, 2009 8:20 pm by anil kumar