How can I get the screen size in the air?

In the AS3 code for Air, how can I get the width and height of the screen of the mobile device on which it works?

+4
source share
4 answers

Check the Screen object for how to do this:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Screen.html#includeExamplesSummary

You can quite easily determine the dimensions of your NativeWindow, then find it on the screen and see the borders by following these steps:

var appBounds : Rectangle = stage.nativeWindow.bounds; var screen : Screen = Screen.getScreensForRectangle( appBounds )[0]; var screenBounds : Rectangle = screen.bounds; 
+6
source

If you use emulators on your desktop, the features will return the resolution of your computer, but not the emulated device.
Just use the step for this:

trace(stage.fullScreenWidth, stage.fullScreenHeight);

+12
source

another method, besides chubbard's answer, is to simply use the Capabilities class, which also works outside of AIR:

 import flash.system.Capabilities; var screenWidth:Number = Capabilities.screenResolutionX; var screenHeight:Number = Capabilities.screenResolutionY; 
+4
source

Set the scene scale mode to "no border":

 import flash.display.StageScaleMode; stage.scaleMode = StageScaleMode.NO_BORDER; 
0
source

Source: https://habr.com/ru/post/1379910/


All Articles