Reputation: 1712
I would like my application developed for the ipad to appear only in landscape view mode and still have it rotate when the ipad is rotated to the opposite side( support 2 out of 4 rotation possibilities)
how can it be done in as3?
Thanks
Upvotes: 0
Views: 626
Reputation: 759
Set the aspectRatio to landscape and autoOrients to true in the application descriptor, but that is not enough. In your code, you also need to listen for OrientationChanging events dispatched by the Stage object and call preventDefault() on the event object if the stage is trying to rotate to an orientation which you don't support. Something like:
function orientationChangeListener(e:StageOrientationEvent)
{
if (e.afterOrientation == "rotatedLeft" || e.afterOrientation == "rotatedRight")
{
e.preventDefault();
}
}
Note that the orientations are relative to the default orientation of the device, which is portrait for phones and landscape for tablets (usually).
(Also, this didn't work on Android before AIR 2.7 and still won't work on devices running Froyo.)
Upvotes: 1