ActionScript2011.05.09 12:09
프로그램이 완전히 뜨면 자동 업데이트를 하도록 설정 해야 한다.

메인.mxml 파일
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
    width="200"
    height="70"
    creationComplete="checkForUpdate()">

    <mx:Script>
    <![CDATA[
        import flash.events.ErrorEvent;
        import air.update.ApplicationUpdaterUI;
        import air.update.events.UpdateEvent;
        import mx.controls.Alert;
      
        private var updateInit:Boolean = false;
        private var appUpdater:ApplicationUpdaterUI = new ApplicationUpdaterUI();
  
        private function checkForUpdate():void {
            NativeApplication.nativeApplication.addEventListener( Event.EXITING,
                function (e:Event):void {
                    var opened:Array = NativeApplication.nativeApplication.openedWindows;
                    for (var i:int = 0; i < opened.length; i ++) {
                        opened[i].close();
                    }
            });  
  
            appUpdater.updateURL = "http://xxx.xxx.xxx.xxx/updatesample/update.xml";
            appUpdater.isCheckForUpdateVisible = false;
            appUpdater.addEventListener(UpdateEvent.INITIALIZED, onUpdate);
            appUpdater.addEventListener(ErrorEvent.ERROR, onError);
            appUpdater.initialize();

            if (자동업데이트여부 == 1) {
              onInit();
            }
        }

        private function onInit():void {
            if (updateInit == false) {
               appUpdater.initialize();
               upateInit = true;
            }
            else {
               appUpdater.isCheckForUpdateVisible = true;
               onUpdate();
            }
        }

        private function onError(event:ErrorEvent):void {
            Alert.show(event.toString());
        }
      
        private function onUpdate(event:UpdateEvent):void {
            appUpdater.checkNow(); // Go check for an update now
        }
  
    ]]>
    </mx:Script>
    ~~~~~~
</mx:WindowedApplication>

update.xml 파일 (Server-side XML file)
<?xml version="1.0" encoding="utf-8"?>
<update xmlns="http://ns.adobe.com/air/framework/update/description/1.0">
  <version>v1.1</version>
  <url>http://yourserver/updatesample/UpdateSample.air</url>
  <description><![CDATA[
v1.1
  * These notes are displayed to the user in the update dialog
  * Typically, this is used to summarize what's new in the release
  ]]></description>
</update>


신고

'ActionScript' 카테고리의 다른 글

웹서버  (0) 2011.05.11
자신의 IP 외부에서 알아오기  (0) 2011.05.09
랜카드에 할당된 IP 알아내기  (0) 2011.05.09
자동 업데이트  (0) 2011.05.09
AIR의 OS별 File.applicationStorageDirectory Paths  (0) 2011.03.15
DockIcon Click 이벤트 처리  (0) 2011.03.04
Posted by sanghwa

티스토리 툴바