2011-11-07 150 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(); 

他们都应该是要么窗口或飞溅。