Flash Tutorial Android App Orientation Change Size AS3
Learn how to program app orientation for Android device turning features. When the mobile device user flips or rotates the view mode you want to make sure you account for that. Luckily it is simple to do using Actionscript 3.0 and Flash. We use the stage event of "RESIZE" and add a listener to that. The corresponding function is where we place any code we like to manipulate the orientation or dynamic sizes of things in the view screen of the user.
// Actionscript 3.0 Android App View Modes Script For App View Orientation
import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
// Create stage instance and manipulate 2 of its properties
var appStage:Stage = myApp.stage;
appStage.scaleMode = StageScaleMode.NO_SCALE;
appStage.align = StageAlign.TOP_LEFT;
// Function that executes each time a phone or device is rotated
function orientateMyApp(event:Event):void {
var device_width:int = appStage.stageWidth;
var device_height:int = appStage.stageHeight;
// Condition that allows toggling between view modes
if(device_width > device_height){
myApp.gotoAndStop("wide_view");
} else {
myApp.gotoAndStop("tall_view");
}
}
// Add an event listener for the resize event of the stage instance
appStage.addEventListener(Event.RESIZE, orientateMyApp);