Search code examples
actionscript-3airadobe

AS3/AIR device landscape or portrait?


On startup I want to check whether the device is in portrait or landscape mode, so far I have:

var startOrientation:String = stage.orientation;
        trace('startOrientation: '+ startOrientation);
        if (startOrientation == "default")
        {


        }
        if (startOrientation == "upsideDown")
        {


        }

But this doesnt tell me if its landscape or portrait.


Solution

  • When I do :

    trace(stage.orientation);
    

    I get "rotatedRight"

    stage.orientation can be one of :

    public static const DEFAULT : String = "default";
    public static const ROTATED_LEFT : String = "rotatedLeft";
    public static const ROTATED_RIGHT : String = "rotatedRight";
    public static const UNKNOWN : String = "unknown";
    public static const UPSIDE_DOWN : String = "upsideDown";
    

    There is also the stage.deviceOrientation property which can be used to determine the physical orientation of the device.