设置Adobe Air应用程序属性
除了所有創建?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應用程序的根文件。
<rootContentsystemChrome="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,如需轉載請自行聯系原作者
總結
以上是生活随笔為你收集整理的设置Adobe Air应用程序属性的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux命令技巧
- 下一篇: 解决warning LNK1166: c