问题
Hey so i am developing an android application using action script(the adobe air one) since the screen size of my .swf application is appox 840X480... Can i detect the screen size of the android device running application at runtime and set the screen size accordingly?? if so How?? P.S - I'm still rookie at Action-script Thank You
回答1:
Basically, to make your app liquid (or responsive). Follow the following steps:
Set the stage align and scale modes:
stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT;
Listen for resize events on the stage:
stage.addEventListener(Event.RESIZE, stageResizeHandler); function stageResizeHandler(e:Event):void { stage.stageWidth; //how big the width is stage.stageHeight; //how big the height is. //so if you had a box, and you wanted it centered on the screen: box.x = (stage.stageWidth - box.width) * .5; box.y = (stage.stageHeight - box.height) * .5; //draw a background graphics.clear(); graphics.beginFill(0xFF0000); graphics.drawRect(0,0,stage.stageWidth, stage.stageHeight); graphics.endFill(); }
If, you just want to know the physical size of the display, you can do so in the Capabilities
class:
Capabilities.screenResolutionX;
Capabilities.screenResolutionY;
OR
stage.fullScreenWidth;
stage.fullScreenHeight;
This usually doesn't include any tool bars /notification bars though.
If you just want your content scaled, then set the scale mode to whatever you'd like:
stage.scaleMode = StageScaleMode.NO_BORDER;
//this will zoom in your app until it fills the whole screen, though it may crop it a bit if needed.
To see other scaling modes, look here
来源:https://stackoverflow.com/questions/28092972/how-to-determine-and-set-screen-size-at-run-time-using-action-script