-->

Can we change stage size dynamically?

2019-09-21 09:58发布

问题:

Am working on flash cs6 and AIR 14.I developed one app i want to adjust that app to all android and ios devices.for that i want to change my stage size dynamically according to screen resolution of device.Is it possible to do that.if yes how ?

回答1:

Yes, It is possible.

First thing you need to do is the following: (as soon as your application has access to the stage)

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align     = StageAlign.TOP_LEFT;

This will make your stage not scale and become the full size of it's container - in your case an AIR window.

For mobile AIR, this will make it the screen resolution of the device. Though on some high-density displays (iPhone) by default you may get half the native resolution of the device, but scaled x2 so it's still fullscreen. You can adjust this when you build the application in AIR if needed.

For desktop AIR, you can programmatically change the stage by resizing the NativeWindow.

stage.nativeWindow.width = 1234;  //set the width of the stage's window (which will in turn set the stage size if scaleMode is NO_SCALE)