AIR 移动始终处于横向状态

发布于 2024-12-25 23:16:19 字数 330 浏览 2 评论 0原文

我正在 AIR mobile 中制作一个应用程序,我需要始终处于横向模式。在大多数设备上,这没问题,但在某些设备(例如摩托罗拉 XOOM)上,应用程序会以横向方式启动。至少在 Flash Builder 4.5 附带的内置模拟器上是这样。我不知道这是否是模拟器的问题,或者 XOOM 的方向是否与大多数设备不同。 无论如何,我想确保设备始终处于横向模式。这可以很容易地检查:

if(stage.stageWidth<stage.stageHeight){
 //rotate screen;
}

我需要在 if 语句中放入什么来确保它的方向正确?

谢谢。

I am making an app in AIR mobile that I need to be in landscape mode all the time. On most devices this is OK, but on some devices (Motorola XOOM for example) the app launches in landscape. At least on the build in emulator that comes with Flash Builder 4.5. I don't know if this is a problem with the emulator or if the XOOM has different orientations than most devices.
Anyway, I want to make sure that the device is always in landscape mode. This can be checked easily:

if(stage.stageWidth<stage.stageHeight){
 //rotate screen;
}

What do I need to put in if statement to make sure that it is properly oriented?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

只是在用心讲痛 2025-01-01 23:16:19

在 *-app.xml 文件中,您可以定义应用程序应如何操作:

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

In the *-app.xml file you can define how application should act:

<aspectRatio>landscape</aspectRatio>
<autoOrients>true</autoOrients>
装纯掩盖桑 2025-01-01 23:16:19

即使在application.xml中将aspectRatio设置为landscape并且将autoOrients设置为false,有时在移动air 3.1应用程序的第一帧期间设备的方向设置不正确,因此stage.stageWidth将返回两个尺寸中较小的一个。几帧后,它将翻转到正确的方向。这可能就是你亲眼所见的。

因此,如果您需要在应用程序首次加载时了解横向舞台尺寸,请使用:

var width :Number = Math.max(stage.stageWidth, stage.stageHeight);
var height :Number = Math.min(stage.stageWidth, stage.stageHeight);

您不需要手动旋转整个应用程序,但具体方法如下:

this.rotationX = 90

Even with aspectRatio set to landscape and autoOrients set to false in application.xml, sometimes a device's orientation is incorrectly set during the first frame of a mobile air 3.1 app, so stage.stageWidth will return the smaller of the two dimensions. Several frames later it will flip to the correct orientation. This could be what you witnessed.

So if you need to know the landscape stage dimensions when your app first loads, use:

var width :Number = Math.max(stage.stageWidth, stage.stageHeight);
var height :Number = Math.min(stage.stageWidth, stage.stageHeight);

You should not need to rotate your entire app manually, but here's how:

this.rotationX = 90
ζ澈沫 2025-01-01 23:16:19

您应该小心锁定应用程序中的旋转,如果您向Apple商店提交,如果应用程序无法适应倒置的设备,您可能会被拒绝。许多设备的“默认”方向有所不同,但使用横向的起始宽高比设置应用程序描述符应该可行。在 AIR 3.3 中进行了一项更改,设置 stage.aspectRatio 将保持预期的宽高比,无论设备的默认方向或设备是否颠倒。

您需要

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

在应用程序描述符中设置:。您还需要设置

-swf-version=16

编译器选项。通过这些设置和 AIR 3.3,应用程序将保持横向宽高比,无论设备旋转到设备的“顶部”是在左侧还是右侧。将长宽比设置为纵向将使设备保持纵向长宽比,即使设备倒置也是如此。

You should take care in locking rotation in your app, if you ever submit to the Apple store you can be denied if the app won't adjust to the device being held upside down. Many devices differ in what their 'default' orientation is, but setting your app descriptor with a starting aspect ratio of landscape should work. In AIR 3.3 there is a change so that setting stage.aspectRatio will keep the expected aspect ratio, regardless of the device's default orientation, or the device being upside down.

You need to set:

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

in your app descriptor. You also need to set

-swf-version=16

in your compiler options. With these setting and AIR 3.3, the app will hold a landscape aspect ratio, regardless if the device is rotated to the 'top' of the device is on the left or the right. Setting the aspect ratio to portrait will make the device keep portrait aspect ration, even if the device is held upside down.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文