2012-07-13 80 views
2

在启动时我要检查设备是否在纵向或横向模式,所以到目前为止,我有:AS3/AIR设备的风景或肖像?

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


     } 
     if (startOrientation == "upsideDown") 
     { 


     } 

但这并不告诉我,如果它的横向或纵向。

回答

2

当我这样做:

trace(stage.orientation); 

我得到 “rotatedRight”

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财产用于确定设备的物理方向。

+1

问题是特别要求的纵向/横向模式...取向,OTOH,提供了设备WRT的定位它是如何设计的正常保持例如有硬键盘的设备的默认方向为横向。 – catholicon 2013-07-31 23:19:10

3

好了,所以不知何故以上贴有“答案”的字面只有答案正是有问题的人已经知道了...... stage.orientation不会让你知道,如果它的横向或纵向....

这可能不是你想要的东西......但是怎么样呢?

var isLandscape:Boolean = this.stage.stageWidth>this.stage.stageHeight;