2012-11-02 52 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" 
相關問題