【问题标题】:How to set equivilent of android:screenOrientation="sensorLandscape" in Adobe AIR for mobile如何在 Adob​​e AIR for mobile 中设置 android:screenOrientation="sensorLandscape" 的等效项
【发布时间】:2012-10-09 05:17:30
【问题描述】:

我有一个 Adob​​e AIR Actionscript for Mobile 项目。我想发布它以使其行为类似于: sensorLandscape “横向,但可以是基于设备传感器的正常或反向横向。” - 来自Android API documentation

我已经设置:

<initialWindow>
    <content>AppName.swf</content>
    <aspectRatio>landscape</aspectRatio>
    <autoOrients>true</autoOrients>
<initialWindow>

在 App.xml 中。

从 FlashBuilder 7 发布调试文件时,结果是在 Nexus 7 上 - 它始终是横向的 - 但它不会随着设备重新定向以显示反向横向。

【问题讨论】:

    标签: actionscript-3 air flash-builder


    【解决方案1】:

    你没有给出任何代码,所以我假设你不听:

    stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, orientationChangeListener, false, 0, true);
    //...
    protected function orientationChangeListener(event:Event):void
        {
            /*
            log("beforeOrientation:" + event["beforeOrientation"].toString()
                 + "\nafterOrientation:" + event["afterOrientation"].toString());
            */
        }
    

    Android 在方向更改时会创建视图的新实例,AIR 不会,因此您必须通过监听方向更改并采取相应措施来对此进行编程,例如通过旋转视图(和调整大小等),还可以检查舞台上的调整大小事件,因为它似乎对屏幕方向变化的响应更快。

    stage.addEventListener(Event.RESIZE, onStageResized, false, 0, true);
    //...
    protected function onStageResized(e:Event=null):void
    {
        trace("sr.Orientation: " + stage.deviceOrientation);
    }
    

    最好的问候

    【讨论】:

    • 谢谢。我正在听调整大小。事实证明,我没有在我的 Android 设备上设置自动旋转。我一打开它 - 一切正常。但是,我相信使用 sensorLandscape 确实有效。在强制运行时 AIR 应用程序中,当我在全局自动旋转设置被锁定时旋转设备时,它不会触发调整大小事件或 ORIENTATION_CHANGE 事件。有谁知道解决这个问题的方法吗?
    猜你喜欢
    • 1970-01-01
    • 2014-03-24
    • 1970-01-01
    • 2012-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-08
    • 1970-01-01
    相关资源
    最近更新 更多