2012年2月15日 星期三

air auto update

環境 : flash builder 4.5(FB) // air sdk 3.0  // appserv 可以架個server抓到update.xml和.air安裝檔 即可
測試 1.0.0(原始安裝檔) 透過指定.xml ==更新==> 1.0.1(之後的更新版本)
專案測試名稱 : testAutoPatch

1.在專案的建置過程中跟一般FB開設專案一樣

2.設定testAutoPatch-app.xml
FB會自動幫你生成testAutoPatch-app.xml
來看裡面的內容吧
找到versionnumber 這個tag
並設定他的版號1.0.0
看你的設計方式 1.0 也可

ps: 這個代表當專案release 的時候 所給予他的版號  將來都會根據這個為依據 去參考update.xml 去check是否要更新你的專案

3. src 下設計一個configuration.xml
內容如下:
<configuration xmlns="http://ns.adobe.com/air/framework/update/configuration/1.0">  <url>http://localhost/update.xml</url>  
<delay>1</delay> 
<dialog name="checkForUpdate" visible="false"/>
<dialog name="downloadUpdate" visible="true"/>
<dialog name="downloadProgress" visible="true"/>         
<dialog name="installUpdate" visible="true"/> 
</configuration> 
configuration xmlns 主要是定義這個adobe auto update configuration , 版本 1.0 (非我們使用的air sdk 的3.0 喔 , 我在這裡卡住過)


http://localhost/update.xml 參考update.xml的依據 (之後會講這個內容)

The delay property 是定期檢查update之間的delay時間 參數(day);
defaultUI :

checkForUpdate : 開起來就會執行update , 就算你沒有update 都會跳一個dialog出來 ;
downloadUpdate : 下載Update dialog box
downloadProgress : 下載Progress dialog box
installUpdate : install update dialog box

ps: 還有不需要建置configuration.xml 去設計這個air auto update 其實大同小異 方式都差不多

4.release 出來 此就為最新的 1.0.0 的testAutoPatch.air install file (此為原始發佈給使用者用的.air)

========================================================================
web簡易設計

5.有版本上的控制的人 其實會常常把release 出來的  .air 安裝檔 放入server 上 ~ 也會順便去更新這個update.xml  (其實就有點web service的意思了 在這裡就不詳述這個細節勒 因為做法很多)

1.0.1
http://192.168.106.93/AutoUpdate/testAutoPatch.air



versionNumber : 這個最主要就是要描述http://localhost/AutoUpdate/testAutoPatch.air 的版本是多少
url : release 出來 .air 的位置
description : 此版本的新增描述

6. 這裡我是使用appServ去架一個簡單的http server ~ 把未來發布出來的testAutoPatch.air和update.xml 放到指定的目錄 , 以供程式執行的時候會自動去check update

========================================================================

7.撰寫基本的testAutoPatch.mxml


 
  
  
 
 
  
 
 
  
 


//使用ApplicationUpdateUI 套件

private var _updater:ApplicationUpdaterUI ;
_updater.configurationFile = new File("app:/configuration.xml"); //設定讀取的configuration.xml 的位置

ps:configuration.xml 內容xmlns="http://ns.adobe.com/air/framework/update/configuration/1.0別亂改
要不然一定會跳出error事件

本地的設計上都沒有錯誤的話
_updater.checkNow(); //會自動去檢查是否要使用update 視窗勒 ~


程式一執行的時候


準備可以install


===================================