0
votes

I have an Adobe AIR Actionscript for Mobile project. I want to publish so that it behaves like: sensorLandscape "Landscape orientation, but can be either normal or reverse landscape based on the device sensor." - from Android API documentation.

I have set:

<initialWindow>
    <content>AppName.swf</content>
    <aspectRatio>landscape</aspectRatio>
    <autoOrients>true</autoOrients>
<initialWindow>

in the App.xml.

The result is on a Nexus 7 when publishing a debug file from FlashBuilder 7 - is that it is always landscape - but it does not re-orient with the device to show reverse landscape.

1

1 Answers

0
votes

you haven't give any code so I asssume that you do not listen to:

stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, orientationChangeListener, false, 0, true);
//...
protected function orientationChangeListener(event:Event):void
    {
        /*
        log("beforeOrientation:" + event["beforeOrientation"].toString()
             + "\nafterOrientation:" + event["afterOrientation"].toString());
        */
    }

Android on orientation change creates new instance of the view, AIR doesn't so you have to program this by listening to orientation change and act accordingly e.g. by rotating your view (and resizing etc.) also check for the resize event on stage as it seems to respond quicker to screen orientation change.

stage.addEventListener(Event.RESIZE, onStageResized, false, 0, true);
//...
protected function onStageResized(e:Event=null):void
{
    trace("sr.Orientation: " + stage.deviceOrientation);
}

best regards