AIR 移动始终处于横向状态
我正在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 *-app.xml 文件中,您可以定义应用程序应如何操作:
In the *-app.xml file you can define how application should act:
即使在application.xml中将aspectRatio设置为landscape并且将autoOrients设置为false,有时在移动air 3.1应用程序的第一帧期间设备的方向设置不正确,因此stage.stageWidth将返回两个尺寸中较小的一个。几帧后,它将翻转到正确的方向。这可能就是你亲眼所见的。
因此,如果您需要在应用程序首次加载时了解横向舞台尺寸,请使用:
您不需要手动旋转整个应用程序,但具体方法如下:
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:
You should not need to rotate your entire app manually, but here's how:
您应该小心锁定应用程序中的旋转,如果您向Apple商店提交,如果应用程序无法适应倒置的设备,您可能会被拒绝。许多设备的“默认”方向有所不同,但使用横向的起始宽高比设置应用程序描述符应该可行。在 AIR 3.3 中进行了一项更改,设置 stage.aspectRatio 将保持预期的宽高比,无论设备的默认方向或设备是否颠倒。
您需要
在应用程序描述符中设置:。您还需要设置
编译器选项。通过这些设置和 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:
in your app descriptor. You also need to set
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.