2012-11-02 49 views
2

我刚刚在iPhone 5上测试了我的第一款Flex移动应用程序,但由于我认为它不适合新的4英寸屏幕,是否有人知道这是否可行?的Flex 4.6 SDK)适用于iPhone 5屏幕的Flex移动应用程序

+0

要使用iOS中新的屏幕尺寸;我相信你需要更新你的iOS SDK。您可以从他们的开发人员门户网站获取Apple的SDK。还有一个地方可以在Flash Builder中指定iOS SDK。在Flash Builder 4.6中,我相信你需要在MAC上才能更改iOS SDK。 – JeffryHouser

回答

3

这是一个小傻瓜,但它的工作原理。首先,确保你有the latest AIR SDKinstalled in your Flash Builder eclipse plug in directory,这将确保下面的技巧实际工作。

现在,转到您的项目主要MXML文件(如果您正在构建基于视图的项目,该项目将成为ViewNavigatorApplication类实例)。在打开的ViewNavigatorApplication标签中,为splashScreenImage设置一个值为“@Embed('[email protected]')的属性“它应该是确定这样的事情...

<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
         xmlns:s="library://ns.adobe.com/flex/spark" 
         firstView="views.myFirstView" 
         splashScreenImage="@Embed('[email protected]')"> 

现在,做一个640瓦特X 1136h闪屏PNG并将其命名为 “[email protected]”。将该映像文件放在项目的根目录(可能是您的“src”目录)中。编译你的iPhone 5目标,瞧!

事实证明,AIR将查找较大的启动屏幕文件作为您指定的iPhone 5屏幕尺寸的指标。在app.xml文件中没有设置。没有代码中的属性。就是那个splashScreenImage文件的名字。

这很明显,是吧?

只要为不同的屏幕尺寸创建不同的布局Rich Tretola有一本很棒的和便宜的书,带有Flex 4.5的iOS应用程序,讨论使用@media查询进行响应式设计。 His website has an excerpt that might help ...但这本书便宜,实用且快速阅读。

+0

我没有将Embed信息添加到应用程序splashScreenImage中(因为我使用的组件是为不同的分辨率提供不同的图像),但我确实将“[email protected]”图像放在src目录中,并构建了应用程序与iOS 6.1 SDK和正确显示使用iPhone 5上的全分辨率。 所以希望这对于那些使用像我这样的组件,而不必建立一个应用程序来测试第一等有用。我用Flash Builder 4.7和AIR 3.8。 – Tyler

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('[email protected]')"/> 
    <s:SplashScreenImageSource id="img_720_1280" source="@Embed('Default_720_1280.png')"/> 
    <s:SplashScreenImageSource id="img_1080_1920" source="@Embed('[email protected]')"/> 

</s:SplashScreenImage> 

....

splashScreenImage="DynamicSplashScreen" 
相关问题