在 XML 設定檔中定義更新設定

更新設定檔為 XML 檔,當中可以含有下列元素:

  • updateURL — 字串。代表更新描述器在遠端伺服器上的位置。任何有效的 URLRequest 位置皆可。您必須定義 updateURL 屬性,無論是透過設定檔或透過指令碼定義皆可 (請參閱 定義更新描述器檔案並將 AIR 檔案加入您的網站伺服器 )。您必須先定義這個屬性才能使用更新程式 (亦即,在呼叫 Updater 物件的 initialize() 方法之前;請參閱 初始化更新架構 )。

  • delay —數字。代表檢查更新的時間間隔,以天數表示 (允許使用 0.25 之類的值)。值為 0 (預設) 時表示更新程式不會執行自動定期檢查。

除了 updateURL delay 元素以外,ApplicationUpdaterUI 的設定檔還可以含有下列元素:

  • defaultUI dialog 元素清單。每一個 dialog 元素都有一個 name 特質,該特質會對應到使用者介面中的對話方塊。每一個 dialog 元素都有一個 visible 特質,該特質會定義對話方塊是否要顯示。預設值是 true name 特質的可能值包括:

    • "checkForUpdate" —對應至「檢查更新」、「沒有更新」和「更新錯誤」對話方塊

    • "downloadUpdate" —對應至「下載更新」對話方塊

    • "downloadProgress" —對應至「下載進度」和「下載錯誤」對話方塊

    • "installUpdate" —對應至「安裝更新」對話方塊

    • "fileUpdate" —對應至「檔案更新」、「檔案沒有更新」和「檔案錯誤」對話方塊

  • "unexpectedError" —對應至「未預期的錯誤」對話方塊

    設定為 false 時,對應的對話方塊就不會在更新程序中顯示。

以下提供一個 ApplicationUpdater 架構的設定檔範例:

<?xml version="1.0" encoding="utf-8"?> 
<configuration xmlns="http://ns.adobe.com/air/framework/update/configuration/1.0"> 
      <url>http://example.com/updates/update.xml</url> 
      <delay>1</delay> 
</configuration>

以下提供一個 ApplicationUpdaterUI 架構的設定檔範例,其中含有 defaultUI 元素的定義:

<?xml version="1.0" encoding="utf-8"?> 
<configuration xmlns="http://ns.adobe.com/air/framework/update/configuration/1.0"> 
      <url>http://example.com/updates/update.xml</url> 
      <delay>1</delay> 
      <defaultUI> 
         <dialog name="checkForUpdate" visible="false" /> 
         <dialog name="downloadUpdate" visible="false" /> 
         <dialog name="downloadProgress" visible="false" /> 
      </defaultUI> 
</configuration>

configurationFile 屬性指向該檔案的位置:

ActionScript 範例:

appUpdater.configurationFile = new File("app:/cfg/updateConfig.xml");
JavaScript 範例:
appUpdater.configurationFile = new air.File("app:/cfg/updateConfig.xml");

更新架構的 templates 目錄會包含一個設定檔樣本:config-template.xml。