未分派StageOrientationEvent.ORIENTATION_CHANGING

时间:2016-02-17 00:16:47

标签: ios actionscript-3 mobile air

我在iPhone 4上测试我的starling应用程序,我怀疑这是因为过时的IOS版本而发生的。

package
{

    import flash.events.Event;
    import flash.events.StageOrientationEvent;
    import flash.display.Sprite;

    public class Startup extends Sprite
    {

        public function Startup():void
        {
            addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
        }

        private function onAddedToStage(e:Event):void
        {
            removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);

            stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING, orientationChangeListener);
        }

        private function orientationChangeListener(e:StageOrientationEvent):void
        {
            Debug.write("orientation: " + stage.orientation); //Never called
        }

    }

}

application.xml将autoOrients设置为“true”并将aspectRatio设置为“landscape”,我也尝试按照某些stackoverflow应答中的建议删除aspectRatio,但无济于事。

我的应用程序中永远不会调度StageOrientationEvent.ORIENTATION_CHANGING。

另一个奇怪的事情正在发生,这可能有助于您更好地了解情况:

即使在application.xml中将aspectRatio设置为“landscape”,app也会以纵向模式打开,stage.orientation将返回“rotatingRight”(意为横向)。 我只能通过在application.xml中将aspectRatio设置为“portrait”,然后在运行时手动设置为“landscape”来正确设置横向:

stage.setOrientation(StageOrientation.ROTATED_RIGHT);

2 个答案:

答案 0 :(得分:0)

如果您只想锁定横向模式,那么首先在描述XML中将aspectRatio设置为landscape,将autoOrient设置为true,然后在代码中执行:

stage.setAspectRatio(StageAspectRatio.LANDSCAPE);
stage.autoOrients = true;

该设备不会通过肖像。

答案 1 :(得分:0)

    <autoOrients>true</autoOrients>
    <aspectRatio>landscape</aspectRatio>

应该是同性恋的方式,它一直适用于我们,但我们没有使用此设置发布应用程序与air sdk 18

因为它似乎对你不起作用,你可以尝试使用动态方式作为一种解决方法,就像我们在通用构建中使用一样(在预加载器框架中检测设备iphone / ipad,应用正确的方向,实例化正确的主类) ,在旧设备/ os版本上测试

    <autoOrients>true</autoOrients>
    <aspectRatio>any</aspectRatio>

并尽快调用stage.setAspectRatio(StageAspectRatio.LANDSCAPE);,意思是在main或preloader类构造函数中

相关问题