关于调用ApplicationUpdaterUI后,无法正常关闭进程

AIR桌面程序支持版本更新,可以用ApplicationUpdaterUI来达到更新程序的目的。但调用ApplicationUpdaterUI后,关闭程序有可能会出现当前进程无法注销掉,只能手动杀死当前AIR桌面程序的进程。在网上搜了搜相关资料,找到了个解决办法。

 

[php]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"   
  3.                        xmlns:s="library://ns.adobe.com/flex/spark"   
  4.                        xmlns:mx="library://ns.adobe.com/flex/mx"  
  5.                        closing="closingHandlerByWindow(event)"   
  6.                        showStatusBar="false">  
  7.       
  8.     <fx:Script>  
  9.         <!--[CDATA[  
  10.               
  11.             /** 
  12.              * closingHandlerByWindow 
  13.              * 在关闭主程序前,处理ApplicationUpdaterUI无法正常关闭,进程关不掉问题。 
  14.              *  
  15.              * @param Event evt 
  16.              * @return void 
  17.              * **/  
  18.             protected function closingHandlerByWindow(event:Event):void  
  19.             {  
  20.                 var len:int = nativeApplication.openedWindows.length;  
  21.                   
  22.                 //获取其余窗体,除了主程序  
  23.                 for (var i:int = len - 1; i > 0; i--) {  
  24.                       
  25.                     var win:NativeWindow = nativeApplication.openedWindows[i] as NativeWindow;  
  26.                       
  27.                     if (win && !win.closed) win.close();  
  28.                       
  29.                 }//for end  
  30.                   
  31.             }  
  32.         ]]-->  
  33.     </fx:Script>  
  34.       
  35.     <fx:Declarations>  
  36.     </fx:Declarations>  
  37.       
  38.     <s:layout>  
  39.         <s:VerticalLayout />  
  40.     </s:layout>  
  41.       
  42.     <s:Label text="Hello World"/>  
  43.       
  44. </s:WindowedApplication>  

 

原文:http://flex4examples.wordpress.com/2010/12/30/making-sure-your-air-application-exits-when-using-applicationupdaterui/


转载:http://blog.csdn.net/dante_k7/article/details/6561702

你可能感兴趣的:(关于调用ApplicationUpdaterUI后,无法正常关闭进程)