启动时我想检查设备是处于纵向还是横向模式,到目前为止我已经:
var startOrientation:String = stage.orientation;
trace('startOrientation: '+ startOrientation);
if (startOrientation == "default")
{
}
if (startOrientation == "upsideDown")
{
}
但这并不能告诉我它的风景或肖像。
答案 0 :(得分:3)
好的,所以上面发布的“答案”字面上只回答了问题已经知道的人... stage.orientation不会让你知道它的风景或肖像....
这可能不是你想要的......但是怎么样?
var isLandscape:Boolean = this.stage.stageWidth>this.stage.stageHeight;
答案 1 :(得分:2)
当我这样做时:
trace(stage.orientation);
我得到“rotateRight”
stage.orientation可以是以下之一:
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";
还有stage.deviceOrientation属性,可用于确定设备的物理方向。