2011-10-28 39 views

回答

1

设置的aspectRatio景观和以中将autoOrients在应用程序描述属实,但这是远远不够的。在您的代码中,如果舞台试图旋转到您不支持的方向,则还需要监听由Stage对象调度的OrientationChanging事件,并调用事件对象的preventDefault()。喜欢的东西:

function orientationChangeListener(e:StageOrientationEvent) 
{ 
    if (e.afterOrientation == "rotatedLeft" || e.afterOrientation == "rotatedRight") 
    { 
     e.preventDefault(); 
    } 
} 

注意,方向是相对于设备的默认方向,这对于手机和景观为平板电脑(通常情况下)的画像。

(此外,这并没有在Android 2.7 AIR工作之前,但仍无法运行Froyo的设备上运行。)

+0

花了一些时间,但随后的工作就像一个魅力。请注意,您应该使用StageOrientationEvent.ORIENTATION_CHANGING而不是StageOrientationEvent.ORIENTATION_CHANGE,因为它不是可取消的事件(太迟)。如果你只想让它旋转到相反的方向(向上或向下),你应该使用if(e.afterOrientation!=“rotatedLeft”&& e.afterOrientation!=“rotatedRight”) – Eran