設定Adobe Air應用程式屬性

weixin_33763244發表於2017-11-08

除了所有建立 AIR(Adobe Integrated Runtime )應用程式的需要的資原始檔以外,Adobe AIR應用程式還需要一個應用程式描述檔案,一個用來定義Adobe AIR應用程式基本屬性的XML檔案。

如果你使用Flex Builder 3,這個應用程式描述檔案檔案,在你建立一個新的AIR專案時,被自動的生成。如果你使用Flex 的 AIR SDKs來開發Adobe AIR 應用程式,你需要自己手動建立這個檔案。

Adobe AIR應用程式描述檔案結構

Adobe AIR程式描述檔案application.xml,包含的Adobe AIR程式的全部屬性,如AIR程式的名字,版本,版權資訊,等等之類的。Adobe AIR程式描述檔案能使用任何檔名字。當建立一個新的專案時,Flex Builder 自動建立一個描述檔案。當你打包輸出Adobe AIR應用程式時,不論是用Flex Builder 還是 ADT,都會被重新命名為application.xml,並且放在AIR包的一個特定目錄下。

下面是一個Adobe AIR程式描述檔案的例子:

<?xml version="1.0" encoding="utf-8" ?>
<application appId="com.adobe.air.examples.HelloWorld" version="2.0"
xmlns="http://ns.adobe.com/air/application/1.0.M4">
<name>AIR Hello World</name>
<description>
This is the Hello World sample file from the Adobe AIR documentation.
</description>
<title>HelloWorld -- AIR Example</title>
<copyright>Copyright © 2006</copyright>
<rootContent systemChrome="none"
transparent="true"
visible="true"
width="640"
height="480">
HelloWorld-debug.swf
</rootContent>
<installFolder>Adobe/Examples</installFolder>
<icon>
<image16x16>icons/smallIcon.png</image16x16>
<image32x32>icons/mediumIcon.jpg</image32x32>
<image48x48>icons/bigIcon.gif</image48x48>
<image128x128>icons/biggestIcon.png</image128x128>
</icon>
<handleUpdates/>
<fileTypes>
<fileType>
<name>adobe.VideoFile</name>
<extension>avf</extension>
<description>Adobe Video File</description>
<contentType>application/vnd.adobe.video-file</contentType>
</fileType>
</fileTypes>
</application>

在程式描述檔案中定義Adobe Air程式屬性

在Adobe AIR程式描述檔案根部,包含有一個Adobe AIR程式的下列幾個屬性:

<application appId="com.adobe.air.HelloWorld" version="1.0"
xmlns="http://ns.adobe.com/air/application/1.0.M4">

appID 一個Adobe AIR應用程式唯一的識別符號。這個屬性值限定在下列字元範圍之內:

  • 0-9
  • a-z
  • A-Z
  • . (dot)
  • - (hyphen)

這個值必須包含17到255個字元。

這個appId The 字串典型的使用一個點分隔符層級,用一個反轉的DNS域名地址,一個JAVA包或類名,或者一個OS X通用的型別標識。這個類似DNS的形態不是強制的,不會在這個名字和域名之間建立任何聯絡。

version 指定的版本資訊(他和Adobe AIR執行時的虛擬機器版本沒有關係)。這個版本串是Adobe AIR應用程式設計者定義的。Adobe AIR虛擬機器不會通過任何途徑解釋這個版本串。因此版本”3.0″並不假定是比當前的”2.0.”或例如:“1.0″, “.4″, “0.5“, “4.9″, “1.3.4a” 版本更高

xmlns AIR 的名字空間,你必須用預設的XML名字空間定義,這個名字空間將隨著Adobe AIR的每個發行版本而改變。

定義Adobe AIR應用程式的名字,標題,描述,版權,和安裝目錄

name 的名字。必須定義在這個元素裡。

<name>TestApp</name>

在windos系統裡,它顯示在應用程式的標題條和windows的開始選單裡。在MAC OS裡,當Adobe AIR應用程式執行時它顯示在選單條裡。

title (可選項)顯示在Adobe AIR應用程式安裝描述裡。

<title>TestApp from Adobe Systems Inc.</title>

description (可選項) 顯示在Adobe AIR應用程式安裝描述裡。

<description>An MP3 player.</description>

copyright (可選項) Adobe AIR應用程式的版權資訊。

<copyright>Copyright © 2006 [YourCompany, Inc.]</copyright>

installFolder (可選項) 確定預設安裝目錄的子目錄。

<installFolder>Acme</installFolder>

在Windows系統裡某人的安裝子目錄是Program Files 目錄。在Mac OS系統裡,它是./Applications 目錄。例如:installFolder屬性是設為“Acme”並且Adobe AIR應用程式名字是“ExampleApp”,那麼這個Adobe AIR應用程式在wodows系統裡將被安裝在C:\Program Files\Acme\Example,而在Mac OS裡將被安裝在./Applications/Acme/Example.app

如果你想指定巢狀的子目錄,可以使用”/”字元作為目錄分隔符,類似下面那樣:

<installFolder>Acme/Power Tools</installFolder>

installFolder屬性可以包含任何Unicode (UTF-8) 字元,除了下列的字元以外,這些字元是被任何檔案系統所禁止使用的。

Character Hex Code
various 0×00 - x1F
* x2A
x22
: x3A
> x3C
< x3E
? x3F
\ x5C
| x7C

installFolder 的屬性是可選的。如果你沒有指定這個屬性,這個Adobe AIR應用程式將被安裝在基於name 屬性的預設安裝子目錄。

定義Adobe AIR應用程式的 rootContent元素

application.xml檔案也指示了rootContent檔案。這個檔案是第一個被Adobe AIR應用程式載入執行的。它可能是一個SWF檔案或一個HTML檔案。

這個為rootContent 指定的值是一個相對於application.xml檔案根的URL。例如,在下列rootContent 的屬性裡,AIRTunes.swf 檔案(在和application.xml 檔案相同的目錄下)被定義為Adobe AIR應用程式的根檔案。

<rootContent
systemChrome="none"
transparent="true"
visible="true"
height="400"
width="600">
AIRTunes.swf
</rootContent>

rootContent元素設定被載入執行的根內容的視窗之內的特性。

systemChrome 如果你設定這個特性為standard,將顯示系統chrome(這個詞不知如何翻譯,應該是視窗基本的風格樣式),如果你設定為none,系統chrome不會被顯示。當使用Flex WindowedApplication 元件,這個元件將應用自定的chrome。

transparent 如果想應用程式視窗支援aplha混合(透明效果)設定它為 “true”.當一個視窗被建立後,這個transprent屬性不能再被改變。一個具有透明屬性的視窗將顯示比較慢,並且需要更多的額外的記憶體。

重要提示: 當systemChrome=”none”時只能設定transparent=”true” 。

visible 如果你想主視窗第一次建立時被隱藏,設定這個值為“false”。預設值是“true”。

你可以在你的Adobe AIR程式程式碼中讓主視窗初始化時隱藏,然後設定它的位置和大小。然後你可以通過設定stage.window.visible (主視窗的)屬性為true,來顯示它。跟多詳細說明請看Working with windows.

height, width 應用程式的視窗的高和寬。如果不設定這個特性,視窗的大小將由根的SWF檔案決定設定,或者HTML情況,被作業系統設定。如果你設定visible特性為“false”,你能加入程式碼去調整視窗的寬和高的屬性(在設定visible屬性為true之前) 。

指定Adobe AIR程式的icon圖示檔案

icon 屬性指定一個或更多的被Adobe AIR應用程式檔案使用的icon圖示檔案。包括一個圖示icon是可選的。如果你沒有指定一個icon屬性,作業系統將顯示預設的圖示。

這個指定的路徑是相對於Adobe AIR應用程式的根目錄。支援PNG, GIF, 和JPEG的檔案格式。你能指定下列所有的icon圖示大小。

<icon>
<image16x16>icons/smallIcon.png</image16x16>
<image32x32>icons/mediumIcon.jpg</image32x32>
<image48x48>icons/bigIcon.gif</image48x48>
<image128x128>icons/biggestIcon.png</image128x128>
</icon>

如果指定了一個圖片,它必須是指定的大小。如果所有的大小沒有提供,最接近的將被縮放到適合的大小,供作業系統提供給使用者顯示。

主意:圖示檔案不是自動被加入Adobe AIR程式包裡的。當Adobe AIR應用程式被打包時,這個icon圖示檔案必須被包含在當前本地相對路徑下。

一個包含更新介面的訊號(翻譯比較怪異Signaling the inclusion of an update interface)

通常的,Adobe AIR安裝和更新應用程式使用預設的安裝對話方塊。然而你也能使用AIR Updater API為更新一個Adobe AIR應用程式,定義你自己的更新機制。去指定你的應用程式自己管理更新處理控制程式碼,你必須包括handleUpdates元素在Adobe AIR應用程式描述檔案裡:

<handleUpdates/>

當你的Adobe AIR應用程式的安裝版本,在應用程式描述檔案裡,包括handleUpdates元素,並且使用者雙擊啟動一個新的版本(appID屬性必須匹配,即保證是同一個Adobe AIR應用程式)的AIR檔案,AIR執行時開啟這個應用程式被安裝的版本,而不是預設的AIR應用程式安裝器。你的程式邏輯上能夠決定如何去處理更新操作。

注意:handleUpdates 機制僅僅當應用程式已經安裝並且使用者雙擊AIR檔案時才起作用。

(翻譯比較彆扭參看原文)When the installed version of your application includes the handleUpdates element in the application descriptor file and the user then double-clicks on the AIR file for a new version (the appID attributes must match), the runtime opens the installed version of the application, rather than the default AIR application installer. Your application logic can then determine how to proceed with the update operation.

Note: The handleUpdates mechanism only works when the application is already installed and the user double-clicks the AIR file.

更多資訊,看 Updating applications programatically.

註冊檔案型別(Registering file types)

檔案型別屬性讓你指定一些檔案型別給AIR應用程式註冊,示例如下:

The fileTypes property lets you specify any file types to be registered for the AIR application, as in this example:

<fileTypes>
<fileType>
<name>adobe.VideoFile</name>
<extension>avf</extension>
<description>Adobe Video File</description>
<contentType>application/vnd.adobe.video-file</contentType>
</fileType>
</fileTypes>

fileTypes元素是可選項。如果採用,你能指定一些數量的檔案型別註冊。

The fileTypes element is optional. If present, you can specify any number of file type registrations.

name 和 extension 屬性是每一個fileType 定義必須被包括的。注意extension是不包括字首的。description屬性是可選項。如果指定,作業系統可以用這個屬性值的內容去描述這個檔案型別。contentType也是可選項。

The name and extension properties are required for each fileType definition that you include. Note that the extension is specified without the preceding period. The description property is optional. If specified, the operating system may use the value of the description property to describe the file type. The contentType property is also optional.

當一個檔案型別被一個AIR應用程式註冊,無論何時一個使用者開啟這個型別的檔案,這個程式將被呼叫。如果應用程式已經執行了,AIR將傳送一個呼叫事件給這個執行的例項。否則AIR將首先啟動這個應用程式。在這兩個案例中,檔名和位置能從通過應用程式Shell物件傳送的InvokeEvent物件中被找到。

When a file type is registered with an AIR application, the application will be invoked whenever a user opens a file of that type. If the application is already running, AIR will dispatch the invoke event to the running instance. Otherwise, AIR will launch the application first. In both cases, the file name and location can be retrieved from the InvokeEvent object dispatched by the application Shell object.




    本文轉自 OldHawk  部落格園部落格,原文連結:http://www.cnblogs.com/taobataoma/archive/2008/03/04/1090046.html,如需轉載請自行聯絡原作者


相關文章