StageAspectRatio Enhancements in AIR 3.3
One must have come across many mobile applications(mostly games) that remain in landscape orientation across their lifetime. They start in landscape orientations and remain in landscape orientations irrespective of the orientation in which the device is held or moved. A landscape only application should ideally support both landscape orientations namely Landscape_Left and Landscape_Right and should not auto rotate to any portrait orientation if the device is held in one of the portrait orientations.
Prior to AIR 3.3, StageAspectRatio supported two public constants PORTRAIT and LANDSCAPE. Using one of these values in the aspectRatio tag in the application descriptor would only lead to the application opening up in PORTRAIT or LANDSCAPE orientation respectively. However, the Stage would re-orient in all orientations as per the new device orientation. For example:- with StageAspectRatio set to PORTRAIT, an app would open in PORTRAIT orientation but would reorient to LANDSCAPE_LEFT orientation when device orientation was changed to LANDSCAPE_LEFT.
In order to develop a LANDSCAPE(or PORTRAIT) only mobile application, one was expected to cancel the automatic reorientation by adding a listener to orientationChanging event in the Stage Object by calling preventDefault() method when afterOrientation values were PORTRAIT (or LANDSCAPE).
From AIR.3.3 onwards, developing LANDSCAPE (or PORTRAIT) only applications has been made easier. With the aspectRatio set to LANDSCAPE(or PORTRAIT) and autoOrients set to true the application descriptor,the stage would automatically reorient only in LANDSCAPE (or PORTRAIT) orientations. Handling orientationChanging events and calling preventDefault() is no longer required to achieve this behavior. One can also change the StageAspectRatio at the runtime by calling the Stage.setAspectRatio() with the desired aspect ratio.
New AspectRatio Constant: “ANY”
A new StageAspectRatio constant “ANY” is introduced in AIR 3.3 to assist you in creating applications that should automatically reorient as per the device orientation. Setting the aspectRatio tag in application descriptor to “ANY” would lead to application launching as per the orientation in which the device is held. Such an application would reorient as per the device orientation.
To summarize, Stage orientation is always in sync with the StageAspectRatio set in application descriptor or programmatically in ActionScript unless set otherwise using Stage.setOrientation(). Following table summarizes the supported Stage orienatations as per the device orientation.
| StageAspectRatio | Supported Stage Orientations |
|---|---|
| ANY | PORTRAIT, UPSIDE_DOWN, LANSCAPE_LEFT & LANDSCAPE_RIGHT |
| PORTRAIT | PORTRAIT & UPSIDE_DOWN |
| LANDSCAPE | LANSCAPE_LEFT & LANDSCAPE_RIGHT |
Please Note:-
- AIR 3.3 is currently available only in pre-release.
- Stage.autoOrients needs to be set to true in application descriptor or programmatically using autoOrients property in the Stage class to reorient the Stage automatically as per the device orientation.


