开发AIR与浏览器兼容程序 Targeting AIR & Browser

Setup We love AIR apps' sophisticated standalone application look and we are a big fan of install-free browser SWF apps. That's why we want our applications to run on both AIR and browser platforms. The table below lists my suggestions on developing flex apps targeting both platforms (sorted by importance):

 

Features AIR only classes/functions Jack's Suggestions
Entry point mx.core.WindowedApplication
mx.events.AIREvent
Create own entry point that can adapt to WindowsApplication (AIR) and Application (browser)
Child/popup windows mx.core.Window
mx.managers.WindowedSystemManager
Create own sub window that can adapt to both Window (AIR) and TitleWindow (browser)
Native info/icons flash.desktop.NativeApplication
flash.desktop.Icon/DockIcon/SystemTrayIcon
flash.display.NativeMenu/NativeMenuItem
flash.display.ContextMenu.items
mx.controls.FlexNativeMenu
Browser version does not set app icon while AIR version can do all the fancy things - set icons, set system menus, start when system starts, exit the app
Clipboard & DnD flash.desktop.Clipboard*
flash.desktop.NativeDrag*
Only the AIR version supports native clipboard and DnD
Local file system flash.filesystem.File*
mx.controls.FileSystem*
mx.events.FileEvent
Try not to access the local file system
Screen size flash.display.Screen SWF's 'screen' is the browser display area and in most cases it occupies the whole 'screen'; you can use the Screen info to maximize the AIR window
HTML flash.html.HTML*
mx.controls.HTML
mx.core.FlexHTMLLoader
In AIR, you use this HTML control to display the content; in SWF, you use text components or use the IFrame technique.
Local database flash.data.SQL*
flash.errors.SQLError*
Do not use local database.
Encrypted local store flash.data.EncryptedLocalStore Do not use EncryptedLocalStore or save data in custom encryption format to SharedObject
URL request settings flash.net.URLRequestDefaults In AIR, you can use it to configure authentication and caching. In SWF, you do not configure.
XML signature validation flash.security.* In most cases, you never use this.
ByteArray compression flash.utils.CompressionAlgorithm Rarely used. If you must use it, consider to implement you own ways of compression algorithm to support both AIR and SWF.

InsideRIA recently featured an article on how to transit from browser to AIR.