côdeazur brasil lab

AIR Remote Updater

The AIR Remote Updater is an Actionscript 3 class to automate remote software updates in Adobe AIR applications.

It transparently checks version numbers, downloads the .AIR installer file if needed and triggers the AIR-native update process. It grabs the version number directly from the remote .AIR file without having to download the entire file, eliminating the potential error prone need of having to put a separate descriptor file online along with the .AIR installer file.

Background

An .AIR installer file is a PKZIP archive containing metadata files along with the packaged application files. The files contained in a .AIR installer file are, in this order:

The file we are interested in, /META-INF/AIR/application.xml (the "application descriptor file"), is always the second file in the archive. FZip is used to stream in the remote .AIR until (and only until) the application descriptor file has loaded. We can then close the stream, uncompress that file and extract the version number.

Usage

public function update():void {
   var request:URLRequest = new URLRequest("http://domain.com/yourapplication.air");
   var updater:AIRRemoteUpdater = new AIRRemoteUpdater();
   updater.addEventListener(AIRRemoteUpdaterEvent.VERSION_CHECK, updaterVersionCheckHandler);
   updater.addEventListener(AIRRemoteUpdaterEvent.UPDATE, updaterUpdateHandler);
   updater.update(request);
}
 
protected function updaterVersionCheckHandler(event:AIRRemoteUpdaterEvent):void {
   // The AIRRemoteUpdaterEvent.VERSION_CHECK event is fired
   // as soon as both local and remote version numbers are known. 
   var updater:AIRRemoteUpdater = event.target as AIRRemoteUpdater;
   trace("Local version: " + updater.localVersion);
   trace("Remote version: " + updater.remoteVersion);
   // You can stop execution of AIR Remote Updater at this point 
   // by calling event.preventDefault(), for example to inform the user 
   // that a new version is available and/or ask if she likes to download 
   // and install it. When the user confirms, call AIRRemoteUpdater.update()
   // again with the versionCheck argument set to "false". This will
   // circumvent the version checking procedure and immediately
   // starts to download the remote .AIR installer file to a temporary
   // file on the user's harddisk.
}
 
protected function updaterUpdateHandler(event:AIRRemoteUpdaterEvent):void {
   // The AIRRemoteUpdaterEvent.UPDATE event is fired when
   // the remote .AIR installer file has finished downloading.
   // The event's "file" property contains a reference to the
   // temporary file on the user's harddisk.
   trace("Installer: " + event.file.nativePath);
   // You can stop execution of AIR Remote Updater at this point 
   // by calling event.preventDefault(), for example to inform the user 
   // that the application is about to shut down and update itself.
}

Download

AIR Remote Updater 1.0.004

History

AIR Remote Updater 1.0.004 (09.10.2008)

AIR Remote Updater 1.0.003 (02.25.2008)

AIR Remote Updater 1.0.002 (10.04.2007)

AIR Remote Updater 1.0.001 (08.08.2007)

License

AIR Remote Updater is released under the OSI approved zlib/libpng license.

Author

Claus Wahlers