2

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.

Stefan
  • 5,203
  • 8
  • 27
  • 51
panthro
  • 22,779
  • 66
  • 183
  • 324

2 Answers2

3

Ok so somehow the above posted "Answer" literally only answers exactly what the person with a question already knew... stage.orientation does not let you know if its landscape or portrait....

this may not be exactly what your looking for... but how about something like?

var isLandscape:Boolean = this.stage.stageWidth>this.stage.stageHeight;
RYan
  • 51
  • 2
2

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.

Barış Uşaklı
  • 13,440
  • 7
  • 40
  • 66
  • 1
    The question is specifically asking for portrait/landscape mode... orientation, OTOH, provides positioning of device wrt how it was designed to held normally e.g. there are devices with hard keyboard which have their default orientation as landscape. – catholicon Jul 31 '13 at 23:19