首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Adobe AIR for mobile中设置android:screenOrientation="sensorLandscape“的等价物

如何在Adobe AIR for mobile中设置android:screenOrientation="sensorLandscape“的等价物
EN

Stack Overflow用户
提问于 2012-10-09 13:17:30
回答 1查看 824关注 0票数 0

我有一个Adobe AIR Actionscript for Mobile项目。我想发布,这样它的行为就像: sensorLandscape“横向方向,但可以是基于设备传感器的正常或反向横向。”-来自Android API documentation

我已经设置了:

代码语言:javascript
复制
<initialWindow>
    <content>AppName.swf</content>
    <aspectRatio>landscape</aspectRatio>
    <autoOrients>true</autoOrients>
<initialWindow>

在App.xml中。

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-10-09 16:10:41

你没有给出任何代码,所以我建议你不要听:

代码语言:javascript
复制
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 on orientation change会创建新的视图实例,而AIR并非如此,所以你必须通过监听方向变化来对其进行编程,并采取相应的行动,例如旋转视图(和调整大小等)。还要检查舞台上的调整大小事件,因为它似乎更快地响应屏幕方向的变化。

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

诚挚的问候

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12793228

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档