You want your application to turn appropriately with the device as a user changes the device orientation.
For AIR Mobile applications there are a few places you need to check to ensure that your application gets the orientation event for you to relayout your view to match the device orientation.
To keep watch over the screen orientation you need to control both the Actionscript code along with the Application Descriptor.
The application descriptor adjustment is simple, first find the <initialWindow/> tag and add in the <autoOrients/> tag.
<initialWindow><autoOrients>true</autoOrients></initialWindow>
The next section to check out is your Actionscript code.
To listen to the StageOrientationEvent add an event handler onto the stage. Before you add the listener first make sure that the stage auto orients - that is really simple to do in code. Below is the code to add the listener and the handler.
private function _onAddedToStage(event:Event):void
{
if(stage.autoOrients)
stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, _onStage_OrientationChange);
}
private function _onStage_OrientationChange(event:StageOrientationEvent):void
{
switch(event.afterOrientation)
{
case StageOrientation.DEFAULT:
break;
case StageOrientation.ROTATED_RIGHT:
break;
case StageOrientation.ROTATED_LEFT:
break;
case StageOrientation.UPSIDE_DOWN:
break;
case StageOrientation.UNKNOWN:
break;
}
}
Within the switch..case statement you can handle the layout or state change code as necessary to your application.
+