【发布时间】:2014-01-07 19:46:00
【问题描述】:
在我的 Flex 移动应用程序中,在我的计算机上运行的 AIR“adl”模拟器上一切正常。但是当我将应用程序部署到我的 Android 手机或平板电脑时,我遇到了这个特殊的问题:
应用程序在横向启动时运行良好,但当我以纵向模式启动时,它只显示一个空白屏幕。如果我将它旋转到横向模式,它会立即渲染,我可以将它旋转回纵向模式,它仍然可以工作。
我做了一些调试,似乎在纵向打开时,视图永远不会添加到舞台上,甚至到达creationComplete。但如果我旋转成横向,它会立即旋转。
有什么想法吗?
Main.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
firstView="views.HomeView">
<fx:Metadata>
[ResourceBundle("resources")]
</fx:Metadata>
<!-- Global CSS styles -->
<fx:Style source="styles/AppStyles.css" />
<fx:Script>
<![CDATA[
// Initialize some vars...
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</s:ViewNavigatorApplication>
视图/HomeView.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:components="components.*"
creationComplete="init()" menuKeyPressed="handleMenuKeyPressed(event)"
title="...">
<s:states>
<s:State name="portrait" />
<s:State name="landscape" />
</s:states>
<fx:Script source="ViewHandler.as" />
<fx:Script source="HomeViewHandler.as" />
<fx:Style source="../styles/HomeViewStyles.css" />
.....
<s:Label id="resultsHeading" text="{s('Results')}" fontWeight="bold" addedToStage="setResultsHeadingFont()" />
<s:HGroup width="100%" layoutDirection="{s('layoutDirection')}">
<s:Group id="mainResultsGroup" width="90%">
<s:layout.portrait>
<s:VerticalLayout />
</s:layout.portrait>
<s:layout.landscape>
<s:HorizontalLayout gap="{getScaledNumber(100)}" />
</s:layout.landscape>
<s:VGroup>
.....
这里的init() 直到应用程序处于横向时才会被调用。
-- 更新: 这是我的 application.xml:
<?xml version="1.0" encoding="utf-8"?>
<application xmlns="http://ns.adobe.com/air/application/4.0">
<id>com.myapp</id>
<versionNumber>0.1</versionNumber>
<supportedProfiles>mobileDevice</supportedProfiles>
<filename>MyApp</filename>
<name>
<text xml:lang="en">My App</text>
</name>
<android>
<manifestAdditions><![CDATA[<manifest android:installLocation="auto">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature android:required="true" android:name="android.hardware.touchscreen.multitouch" />
</manifest>]]></manifestAdditions>
</android>
<iPhone>
<InfoAdditions><![CDATA[<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleBlackOpaque</string>
<key>UIRequiresPersistentWiFi</key>
<string>NO</string>
<key>UIPrerenderedIcon</key>
<true />
<key>UIApplicationExitsOnSuspend</key>
<true />
<key>UIDeviceFamily</key>
<array>
<!-- iPhone support -->
<string>1</string>
<!-- iPad support -->
<!--<string>2</string>-->
</array>]]></InfoAdditions>
<requestedDisplayResolution>high</requestedDisplayResolution>
</iPhone>
<initialWindow>
<title>My App</title>
<content>MyApp.swf</content>
<visible>true</visible>
<fullScreen>false</fullScreen>
<autoOrients>true</autoOrients>
<!--<aspectRatio>landscape</aspectRatio>-->
<renderMode>cpu</renderMode>
<systemChrome>standard</systemChrome>
</initialWindow>
<icon>
<image48x48>icons/icon_48.png</image48x48>
<image57x57>icons/icon_57.png</image57x57>
<image72x72>icons/icon_72.png</image72x72>
<image96x96>icons/icon_96.png</image96x96>
<image114x114>icons/icon_114.png</image114x114>
<image144x144>icons/icon_144.png</image144x144>
<!--<image512x512>icons/icon_512.png</image512x512>-->
</icon>
<description>
<text xml:lang="en">
</text>
</description>
</application>
顺便说一句,我正在使用 FlashDevelop。
【问题讨论】:
-
您能发布您的
[Main]-app.xml文件吗?我认为<aspectRatio>或<autoOrients>的值可能设置不正确。 -
@Brian 我更新并添加了它。
-
您使用
landscape和portrait状态做什么? -
尝试在您的应用程序和视图类中添加
preinitialize和initialize侦听器;用这些调试可能会给你更多的线索。 -
@JoshJanusch 我用该代码更新了问题。我用它来选择布局类型
标签: android actionscript-3 apache-flex air