[AIR]AIR Beta 2.0与AIR Beta3.0的差异和AIR Beta 3.0新增API

自从Adobe将AIR由Beta 2.0升级到Beta 3.0(下称Beta 2.0、Beta 3.0),就发现了越来越多的朋友在Beta2.0下面编写的程序,却无法在Beta 3.0下面运行。我在这里总结一下Beta 3.0新增了哪些API?和Beta 2.0与Beta 3.0 之间的差异!

升级你的Beta 2.0到Beta 3.0的步骤:
首先需要修改的是application.xml这个文件。
1、Change xmlns to “http://ns.adobe.com/air/application/1.0.M6”
2、Added <allowBrowserInvocation> as an element of <application>
3、Added <icon> as an element of <fileType>
4、Renamed <title> –> <name>
5、Renamed <name> –> <filename>
6、Renamed <handleUpdates> –> <customUpdateUI> and type is xs:boolean
7、appId was a property within the <application> tag, now is an element tag called <id>
8、version was a property within the <application> tag, now is an element tag <version> 

一个成型的Beta 3.0的application.xml的描述如下:
<?xml version="1.0" encoding="utf-8" ?>
<application xmlns="http://ns.adobe.com/air/application/1.0.M6">
    <id>SampleApp</id>
    <version>1.2</version>
    <filename>Sample</filename>
    <description>Sample app description</description>
    <copyright>Sample app copyright information</copyright>
    <name>Sample Application </name>
    <initialWindow>
         <title>Main Window</title>
         <content>SampleApplication.swf</content>
         <systemChrome>standard</systemChrome>
         <transparent>false</transparent>
         <visible>true</visible>
         <minimizable>true</minimizable>
         <maximizable>true</maximizable>
         <resizable>true</resizable>
         <width>800</width>
         <height>600</height>
         <x>150</x>
         <y>150</y>
    </initialWindow>
    <fileTypes> 
 <fileType>
   <name>AIR.TextFile</name>
   <extension>aptxt</extension>
   <description>AIR Text File</description>
   <contentType>application/vnd.AIR.text-file</contentType>
   <icon>
       <image16x16>icons/Doc1/txt_16.png</image16x16>    
       <image32x32>icons/Doc1/txt_32.png</image32x32>
       <image48x48>icons/Doc1/txt_48.png</image48x48>
           <image128x128>icons/Doc1/txt_128.png</image128x128>
   </icon>    
 </fileType>
 <fileType>
   <name>AIR.ImageFile</name>
   <extension>apimg</extension>
   <description>AIR Image File</description>
   <contentType>application/vnd.AIR.image-file</contentType>
    <icon>
           <image16x16>icons/Doc2/ft_16_16.png</image16x16>    
        <image32x32>icons/Doc2/ft_32_32.png</image32x32>
        <image48x48>icons/Doc2/ft_48_48.png</image48x48>
          <image128x128>icons/Doc2/ft_128_128.png</image128x128>
    </icon>    
  </fileType>  
</fileTypes>
</application>

Beta 3.0 新增API:(详细的内容请看Language Reference doc
New Methods/Properties/Constants

File
File.isPackage : Boolean
File.isSymbolicLink : Boolean 

HTML
HTMLLoader.textEncodingOverride : String
HTMLLoader.textEncodingFallback : String
HTML <frame> attribute allowcrossdomainxhr 

Mouse
MouseEvent.controlKey : Boolean
MouseEvent.clickCount : int
MouseEvent.MIDDLE_CLICK
MouseEvent.MIDDLE_MOUSE_DOWN
MouseEvent.MIDDLE_MOUSE_UP 

Drag and Drop
NATIVE_DRAG_UPDATE : String 

Media
flash.media.scanHardware() 

DRM
NetStream.resetDRMVouchers()
NetStream.setDRMAuthentication() 

Security
flash.securiy.XMLSignatureValidator.useSystemTrustStore : Boolean
flash.securiy.XMLSignatureValidator.revocationCheckSetting : String 

NativeApplication (formerly Shell)
NativeApplication.copy()
NativeApplication.cut()
NativeApplication.redo()
NativeApplication.undo()
NativeApplication.selectAll()
NativeApplication.performKeyEquivalent()
NativeApplication.publisherID. publisherID is an empty string when debugging with adl. However, a command line flag in adl allows you to run with a publisherID, and the Flex 3 debugging UI also has a field for you to enter it. Clients can find their publisherID by installing the app and looking at the META-INF/AIR/publisherid file. 

Local SQL DB
SQLConnection.openAsync()
SQLError.details
SQLConnection.cacheSize
SQLConnection.autoCompact
SQLConnection.pageSize
SQLConnection.cacheSize
SQLMode 

DRM
DRMErrorEvent (error code related properties from DRMStatusEvent has been migrated to DRMErrorEvent)

Beta 3.0中去掉的API:
Removed Methods/Properties/Constants


URLRequest
URLRequest.setLoginCredentials() – use URLRequestDefaults.setLoginCredentialsForHost() instead 

Local SQL DB
SQLStatement.prepare()
SQLStatement.reset()
SQLStatement.prepared : Boolean
SQLEvent.PREPARE
SQLConnection.getFile()
SQLConnection.synchronous
SQLConnection.version
SQLConnection.caseSensitiveLike
SQLError.code 

HTML
window.runtime property for non application HTML pages.
flash.html.JavaScriptObject, use Object class instead
flash.html.JavaScriptArray, use Object class instead
flash.html.JavaScriptFunction, use Object class instead 

NativeWindow
NativeWindowSystemChrome.UTILITY
NativeWindowType.MODAL
NativeWindowInitOptions.hasMenu


Beta 2.0与Beta 3.0之间的差异性:
URI Schemes
“app-resource:” scheme –> “app:” scheme 

File
FileReference.send() –> FileReference.uploadUnencoded()
File.applicationResourceDirectory –> File.applicationDirectory
flash.filesystem.EncryptedLocalStore –> flash.data.EncryptedLocalStore 

Drag and Drop
DragManager –> NativeDragManager
DragOptions –> NativeDragOptions
DragAction –> NativeDragActions
NativeDragEvent.actionsAllowed : DragOptions –> NativeDragEvent.allowedActions : NativeDragOptions 

Mouse
MouseEvent.cmdKey : Boolean –> MouseEvent.commandKey : Boolean
Service Monitor
ServiceMonitor.lastUpdated –> ServiceMonitor.lastStatusUpdate
ServiceMonitor.augmentPrototype() –> ServiceMonitor.makeJavascriptSubclass() 

Screen
Screen.colorDepth : uint –> Screen.colorDepth : int 

NativeApplication (formerly Shell)
flash.system.Shell –> flash.desktop.NativeApplication
Shell.isBoundAsDefaultApplication() –> NativeApplication.isSetAsDefaultApplication()
Shell.bindAsDefaultApplication() –> NativeApplication.setAsDefaultApplication()
Shell.unbindAsDefaultApplication() –> NativeApplication.removeAsDefaultApplication()
Shell.id –> NativeApplication.applicationID
Shell.lastUserInput –> NativeApplication.timeSinceLastUserInput
Shell.shell –> NativeApplication.nativeApplication
Shell.startApplicationAtLogin –> NativeApplication.startAtLogin
Shell.activateApplication –> NativeApplication.activate 

Local SQL DB
SQLEvent.CLEAN –> SQLEvent.COMPACT
SQLConnection.clean() –> SQLConnection.compact()
SQLUpdateEvent.tableName : String –> SQLUpdateEvent.table : String
SQLConnection.attach(): boolean argument removed
SQLConnection.SQLConnection(): boolean argument to constructor removed
The SQLStatement parameters property is now 0-based instead of 1-based. (i.e.: sql.paremeters[1] –> sql.parameters[0]). 

URLRequest
URLRequestDefaults.shouldAuthenticate –> URLRequestDefaults.authenticate
URLRequest.shouldAuthenticate –> URLRequest.authenticate
URLRequestDefaults.shouldCacheResponse –> URLRequestDefaults.cacheResponse
URLRequest.shouldcacheResponse –> URLRequest.cacheResponse 

URLMonitor
URLMonitor.acceptableStatuses –> URLMonitor.acceptableStatusCodes 

Updater
flash.system.Updater –> flash.desktop.Updater 

HTML
HTMLHost.closeWindow() –> HTMLHost.windowClose()
HTMLHost.htmlControl –> HTMLHost.htmlLoader
HTMLControl –> HTMLLoader
HTMLControl.useApplicationDomain –> HTMLLoader.runtimeApplicationDomain
HTMLControl.shouldCacheResponse –> HTMLLoader.cacheResponse
HTMLControl.htmlWidth –> HTMLLoader.contentWidth
HTMLControl.htmlHeight –> HTMLLoader.contentHeight
HTMLControl.domInitialize Event –> HTMLLoader.htmlDOMInitialize : Event
Event.DOM_INITIALIZE –> Event.HTML_DOM_INITIALIZE
flash.events.HTMLUncaughtJavaScriptExceptionEvent –> flash.events.HTMLUncaughtScriptExceptionEvent
Javascript API: window.htmlControl ? window.htmlLoader 

EncryptedLocalStore
EncryptedLocalStore.setItem(name:String, data:ByteArray) –> EncryptedLocalStore.setItem(name:String, data:ByteArray , stronglyBound : Boolean = false) 

以上内容来自:http://labs.adobe.com/wiki/index.php/AIR:Release_Note
欢迎转载,不过请注明:Kenshin Blog和www.k-zone.cn/zblog