设置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应用程序的根文件。

<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,如需转载请自行联系原作者


相关文章
|
机器学习/深度学习 人工智能 计算机视觉
Adobe Photoshop2023无须激活版下载
Adobe Photoshop 2023又简称为ps2023,这是一款十分强大的电脑图像处理软件,相信大家对此都并不陌生,毕竟这可是火遍全国的软件,一直以来都被广泛的应用于平面设计、创意合成、美工设计、UI界面设计、图标以及logo制作、绘制和处理材质贴图等各个领域中,那么该软件到底是为大家提供了什么功能呢?
312 0
|
Windows 容器 内存技术
背水一战 Windows 10 (59) - 控件(媒体类): Image, MediaElement
原文:背水一战 Windows 10 (59) - 控件(媒体类): Image, MediaElement [源码下载] 背水一战 Windows 10 (59) - 控件(媒体类): Image, MediaElement 作者:webabcd介绍背水一战 Windows 10 之 控件(媒...
1105 0
|
文字识别 Windows 容器
背水一战 Windows 10 (62) - 控件(媒体类): InkCanvas 保存和加载, 手写识别
原文:背水一战 Windows 10 (62) - 控件(媒体类): InkCanvas 保存和加载, 手写识别 [源码下载] 背水一战 Windows 10 (62) - 控件(媒体类): InkCanvas 保存和加载, 手写识别 作者:webabcd介绍背水一战 Windows 10 之 ...
1218 0