2011-11-07 147 views
0

我有我的AIR應用程序,即MyAIRApplication準備就緒。我正在嘗試爲它啓動一個啓動畫面。 這裏是我到目前爲止的代碼..AIR應用程序

main.mxml

<?xml version="1.0" encoding="utf-8"?> 
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" 
         creationComplete="showSplash()" 
         visible="false" 
         layout="absolute" 
         showFlexChrome="false"> 
    <mx:Script> 
     <![CDATA[ 
      import components.Splash; 

      import mx.core.Window; 
      import mx.controls.Alert; 
      import mx.events.AIREvent; 

      private var splash:Window; 
      private var splashTimer:Timer; 

      private function showSplash():void { 
       splash = new Splash(); 
       splash.systemChrome = "none"; 
       splash.transparent = true; 

       splash.type = NativeWindowType.LIGHTWEIGHT; 
       splash.addEventListener(AIREvent.WINDOW_COMPLETE, boot); 
       splash.open(); 
      } 

      private function boot(event:AIREvent):void { 
       splashTimer = new Timer(3000, 2); 
       splashTimer.addEventListener(TimerEvent.TIMER_COMPLETE, showApp); 
       splashTimer.start(); 
       this.removeEventListener(AIREvent.WINDOW_COMPLETE, boot); 

      } 

      private function showApp(event:Event):void { 
       splash.close(); 
       splash = null; 

       splashTimer.stop(); 
       splashTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, showApp); 
       splashTimer = null; 

       // My Application .. where I wrote all components 
       var mainWin:WindowedApplication = new MyAIRApplication(); 
       mainWin.activate(); 
       mainWin.visible = true; 
      } 
     ]]> 
    </mx:Script> 
</mx:WindowedApplication> 

Splash.mxml:

<?xml version="1.0" encoding="utf-8"?> 
<mx:Window xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300" 
      showFlexChrome="false" > 
    <mx:Image x="0" y="0" width="600" height="400" source="@Embed('../images/splash-bg.png')" scaleContent="false"/> 

</mx:Window> 

但我現在面臨兩個問題:

  1. 我的AIR應用程序(即MyAIRA應用程序)沒有顯示出來,完成啓動畫面。
  2. 我閃屏越做越左上角顯示總是

誰能請我提供解決方案嗎?

回答

0
  1. var mainWin:WindowedApplication = new MyAIRApplication();

的WindowedApplication是不是這樣的創建。當你的應用程序啓動時,你已經有了一個,使用它。只需將其內容隱藏起來即可顯示。
還有我不知道,關閉飛濺窗口splash.close()將火WINDOW_COMPLETE事件,與trace對此進行確認(如果需要的話改寫爲Event.CLOSE。)

  1. 的Windows默認情況下不居中。獲取屏幕尺寸爲Capabilities.screenResolutionX/Y,計算中心窗口的x/y並致電splash.move(x, y)
0

它也可能有一些與你您鑄造飛濺變種類型窗口,

private var splash:Window; 

但隨後實例它作爲一個新的飛濺

private function showSplash():void { 
       splash = new Splash(); 

他們都應該是要麼窗口或飛濺。