您的位置:首页 > 大数据 > 人工智能

AIR中文帮助 第九章 设置应用程序属性

2009-04-29 13:58 477 查看
应用程序描述文件的结构

应用程序描述文件application.xml,包含了整个程序的属性,如名称,版本,版权等等。任何文件名都可作为程序描述文件,Flex Builder当创建工程时会自动创建描述文件。当打包程序时无论使用Flex Builder还是ADT,都会把描述文件重命名为application.xml。

这里是一个描述文件的例子:

<?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>


定义应用程序描述文件的属性

程序描述文件的根元素为application字段,其包含几个属性:

<application appId="com.adobe.air.HelloWorld" version="1.0"

xmlns="http://ns.adobe.com/air/application/1.0.M4">


appID : 程序唯一标识符,该属性可由下列字符组成:

0-9

a-z

A-Z

. (点)

- (横杆)

该值必须包含17到255个字符。

version :设定程序的版本信息

xmlns :AIR名称空间,每个版本的AIR其名称空间都会不同。

定义程序名称,标题,描述,版权和安装目录

name :应用程序名称,必须定义

<name>TestApp</name>

在Windows中,这个值会显示在程序的标题栏中

title (可选) :在AIR程序安装器中显示

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

description (可选) AIR程序安装时显示

<description>An MP3 player.</description>

copyright (可选) AIR程序的版权信息

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

installFolder (可选) 默认安装目录的子目录

<installFolder>Acme</installFolder>

在Windows中,默认安装子目录为Program Files目录,在Mac OS中,为/Applications 目录。例如安装目录属性为"Acme"和程序名称为"ExampleApp",则程序将被安装在C:/Program Files/Acme/Example 。

使用反斜杠(/) 作为目录分隔符:

<installFolder>Acme/Power Tools</installFolder>

installFolder属性可以包含任意Unicode (UTF-8) 字符,除了下面的:

代码
Character Hex Code

various 0x00 - x1F

* x2A

" x22

: x3A

> x3C

< x3E

? x3F

/ x5C

| x7C

定义rootContent元素

Application.xml也指明了rootContent文件,因为这个文件是第一个被程序载入的。无论是SWF还是HTML文件。

rootContent元素值是一个URL,相对于application.xml文件所在路径,例如下面的rootContent 元素中AIRTunes.swf 文件和application.xml文件在同一个目录:

代码
<rootContent

systemChrome="none"

transparent="true"

visible="true"

height="400"

width="600">

AIRTunes.swf

</rootContent>


rootContent元素的属性值主要设定将被创建的窗口的属性。

systemChrome :如果设置为standard,窗口继承操作系统窗口样式,程序没有透明,如果设置为false,则窗口不继承操作系统窗口样式。当使用Flex WindowedApplication组件时,该组件将应用自己的窗口样式。

transparent :设置为true,则窗口支持Alpha混合,窗口被创建后transprent 属性将不可更改,透明的窗口需要更多内存且渲染速度慢。

重要提示:当systemChrome="none"时你只能设置transparent="true"。

visible :设置为false,使窗口创建后被隐藏。

你可以需要在主窗口创建时先隐藏,等设置好位置和大小后,再通过stage.window.visible 属性设置为true.再显示主窗口。

height, width :主窗口的高度和宽度。

指定图标文件

Icon属性指定一个或多个可使用的图标文件,该属性是可选的,即使没有指定,操作系统会显示默认图标。

图标路径是相对与程序的根目录,PNG, GIF, 和JPEG 格式都支持

<icon>

<image16x16>icons/smallIcon.png</image16x16>

<image32x32>icons/mediumIcon.jpg</image32x32>

<image48x48>icons/bigIcon.gif</image48x48>

<image128x128>icons/biggestIcon.png</image128x128>

</icon>


注意:图标不会自动被添加到AIR包中。

Signaling the inclusion of an update interface

一般情况,AIR 的安装和升级都是使用默认的安装对话框,但是,你可以定义自己的方法使用AIR Updater API来更新程序,要想这样,必须把handleUpdates 元素添加到描述文件中:

<handleUpdates/>

注册文件类型

fileTypes属性指定那些类型将被注册:

<fileTypes>

<fileType>

<name>adobe.VideoFile</name>

<extension>avf</extension>

<description>Adobe Video File</description>

<contentType>application/vnd.adobe.video-file</contentType>

</fileType>

</fileTypes>


Adobe AIR新增功能

这一节给AIR新增的功能做一个概览。

新的运行时类
运行时类的新功能
新的监控伺服类

新的运行时类(runtime classes)

下面都是Adobe AIR新增的运行时类,这些功能不能用于浏览器中运行的SWF:

Clipboard flash.desktop

ClipboardFormats flash.desktop

CompressionAlgorithm flash.utils

ClipboardTransferMode flash.desktop

DockIcon flash.display

DragActions flash.desktop

DragManager flash.desktop

DragOptions flash.desktop

DRMAuthenticateEvent flash.events

DRMStatusEvent flash.events

EncryptedLocalStore flash.filesystem

File flash.filesystem

FileListEvent flash.events

FileMode flash.filesystem

FileStream flash.filesystem

HTMLControl flash.html

HTMLHistoryItem flash.html

HTMLHost flash.html

HTMLPDFCapability flash.html

HTMLUncaughtJavaScriptExceptionEvent flash.html

HTMLWindowCreateOptions flash.html

Icon flash.desktop

InteractiveIcon flash.display

InvokeEvent flash.events

JavaScriptFunction flash.html

JavaScriptObject flash.html

NativeDragEvent flash.events

NativeMenu flash.display

NativeMenuItem flash.display

NativeWindow flash.display

NativeWindowBoundsEvent flash.events

NativeWindowDisplayState
flash.display

NativeWindowDisplayStateEvent
flash.events

NativeWindowErrorEvent
flash.events

NativeWindowIcon
flash.display

NativeWindowInitOptions
flash.display

NativeWindowResize
flash.display

NativeWindowSystemChrome
flash.display

NativeWindowType
flash.display

NotificationType
flash.display

OutputProgressEvent
flash.events

Screen
flash.display

Shell
flash.system

SQLCollationType
flash.data

SQLColumnNameStyle
flash.data

SQLColumnSchema
flash.data

SQLConnection
flash.data

SQLError
flash.errors

SQLErrorCode
flash.errors

SQLErrorEvent
flash.events

SQLErrorOperation
flash.errors

SQLEvent
flash.events

SQLIndexSchema
flash.data

SQLResult
flash.data

SQLSchema
flash.data

SQLSchemaResult
flash.data

SQLStatement
flash.data

SQLTableSchema
flash.data

SQLTransactionLockType
flash.data

SQLTriggerSchema
flash.data

SQLUpdateEvent
flash.events

SQLViewSchema
flash.data

SystemTrayIcon
flash.display

Updater
flash.system

URLRequestDefaults
flash.net

XMLSignatureValidator
flash.utils

TransferableTransferMode
flash.desktop

URLRequestDefaults
flash.net

Updater
flash.system


大多数类只能在AIR程序安全沙箱中可用,不过下面的这些类也可以用在其他沙箱之上:

Door
URLRequest.


运行时类新增功能

下面的类能用在浏览器上,但是AIR下提供了额外的属性和方法:

HTTPStatusEvent
HTTP_RESPONSE_STATUS

responseURL

responseHeaders

URLRequest
followRedirects

manageCookies

shouldAuthenticate

shouldCacheResponse

userAgent

userCache

setLoginCredentials()

URLStream
httpResponseStatus event

Stage
nativeWindow

Security
APPLICATION


大多数这些属性和方法都在AIR程序安全沙漏中使用,不过URLRequest 类也可以用在其他安全沙箱中。

ByteArray.compress() 和ByteArray.uncompress()方法包含一个新的算法参数,允许你选择压缩或zlib 压缩。

新的Flex组件

下面的Flex组件在AIR程序开发时可用:

FileEvent

FileSystemComboBox

FileSystemDataGrid

FileSystemEnumerationMode

FileSystemHistoryButton

FileSystemList

FileSystemSizeDisplayMode

FileSystemTree

HTML

WindowedApplication


监控伺服类

Air.net包包含一些网络监测类,该包也只能在Adobe AIR中使用,需要引入ServiceMonitor.swc文件。

该包包含下列类:

ServiceMonitor
SocketMonitor
URLMonitor
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: