The accelerometer present in iOS devices can detect changes in physical orientation. AIR provides APIs for detecting these changes and determining the device's actual orientation in real space.
Let us see how this is done.
Start by opening chapter8\recipe6\recipe.fla
from the book's accompanying code bundle.
A dynamic text field named output
can be found on the stage. We will use this text field to report any orientation changes experienced by the device.
Perform the following steps to listen for changes in orientation:
Select File | AIR for iOS Settings from Flash Professional's drop-down menu.
From the General tab, check on the Auto orientation checkbox; then click on the panel's OK button.
Create a document class and name it
Main
.Add the following import statements:
import flash.display.MovieClip; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.StageOrientationEvent;
Within the constructor...