2

我刚刚在 iPhone 5 上测试了我的第一个 Flex 移动应用程序,但我假设它不适合新的 4" 屏幕。有人知道这是否已经可行吗?(使用 Flex 4.6 SDK)

4

2 回答 2

3

这有点愚蠢,但它有效。首先,确保在 Flash Builder eclipse 插件目录中安装了最新的 AIR SDK 。这将确保以下技巧确实有效。

现在,转到您的项目主 MXML 文件(如果您正在构建一个基于视图的项目,该项目将是一个 ViewNavigatorApplication 类实例)。在打开的 ViewNavigatorApplication 标记中,为 splashScreenImage 放置一个值为“@Embed('Default-568h@2x.png')”的属性。它应该看起来像这样……</p>

<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                        xmlns:s="library://ns.adobe.com/flex/spark"
                        firstView="views.myFirstView"
                        splashScreenImage="@Embed('Default-568h@2x.png')">

现在,制作一个 640w x 1136h 的初始屏幕 png 并将其命名为“Default-568h@2x.png”。将该图像文件放在项目的根目录(可能是您的“src”目录)中。为您的 iPhone 5 目标编译,瞧!

事实证明,AIR 会寻找较大的初始屏幕文件作为您定位 iPhone 5 屏幕尺寸的指标。app.xml 文件中没有设置。代码中没有属性。就是那个 splashScreenImage 文件名。

这很明显,对吧?

至于为不同的屏幕尺寸创建不同的布局,Rich Tretola 有一本非常便宜的书,iOS Applications with Flex 4.5,它讨论了使用@media 查询的响应式设计。他的网站上有一段可能会有所帮助的摘录……但这本书便宜、实用且易于阅读。

于 2013-05-16T13:18:09.663 回答
2

您可以像这样动态更改启动画面:

<?xml version="1.0" encoding="utf-8"?>
<s:SplashScreenImage xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark">  

    <fx:Script>
        <![CDATA[
            override public function getImageClass(aspectRatio:String, dpi:Number, resolution:Number):Class 
            {
                var x:Number = Capabilities.screenResolutionX;
                var y:Number = Capabilities.screenResolutionY;


                // HTC
                if ((x == 480) && (y == 800)) return img_480_800.source;

                // iPhone 5
                if ((x == 640) && (y == 1136)) return img_1080_1920.source;

                // iPhone 4
                if ((x == 640) && (y == 960)) return img_640_960.source;

                // Samsung galaxy s3
                if ((x == 720) && (y == 1280)) return img_720_1280.source;

                // Samsung galaxy s4
                if ((x == 1080) && (y == 1920)) return img_1080_1920.source;

                // Default
                return img_1080_1920.source;
            } 
        ]]>
    </fx:Script>


    <s:SplashScreenImageSource id="img_480_800" source="@Embed('Default_480_800.png')"/>
    <s:SplashScreenImageSource id="img_640_960" source="@Embed('Default@2x.png')"/>
    <s:SplashScreenImageSource id="img_720_1280" source="@Embed('Default_720_1280.png')"/>
    <s:SplashScreenImageSource id="img_1080_1920" source="@Embed('Default-568h@2x.png')"/>

</s:SplashScreenImage>

……

splashScreenImage="DynamicSplashScreen"
于 2013-09-01T07:25:03.563 回答