Schemaphic Systems Blog

Sharing experiences in Flash, Flex and AIR

AIR Application Updater

leave a comment »

Look for “<version>” tag in the Application-app.xml file which gets generated while creating a WindowedApplication. The value of this tag resembles the current version of the air.

import air.update.ApplicationUpdaterUI;
import air.update.events.UpdateEvent;
import air.update.events.StatusFileUpdateErrorEvent;

var applicationUpdater:ApplicationUpdaterUI;

/*
* Check to see if application update is required
*/
public function checkForApplicationUpdate() : void
{
applicationUpdater = new ApplicationUpdaterUI();
applicationUpdater.updateURL = “update.xml”;//sample update.xml is provided below
applicationUpdater.isCheckForUpdateVisible = false;
applicationUpdater.addEventListener( UpdateEvent.INITIALIZED, onUpdateInitHandler );
applicationUpdater.addEventListener( ErrorEvent.ERROR, onErrorHandler );
applicationUpdater.addEventListener( StatusFileUpdateErrorEvent.FILE_UPDATE_ERROR, onErrorHandler );
}

private function onUpdateInitHandler( event:UpdateEvent ) : void
{
/*checkNow API actually compares the version of the current
installed application from Application-app.xml
with the version from update.xml and acts accordingly.*/
applicationUpdater.checkNow();
}

private function onErrorHandler( event:Event ) : void
{
trace(“onErrorHandler”);
}

checkForApplicationUpdate();

/*************update.xml***************/

<?xml version=”1.0″ encoding=”utf-8″?>
<update xmlns=”http://ns.adobe.com/air/framework/update/description/1.0″&gt;
<version>v2</version>
<url>http://tourdeflex.adobe.com/blogfiles/AIRAutoUpdateSample/server/AIRAutoUpdateSample-v2.air</url&gt;
<description><![CDATA[
v2
* These notes are displayed to the user in the update dialog
* Typically, this is used to summarize what’s new in the release
]]></description>
</update>

Advertisements

Written by Deepanjan Das

July 20, 2010 at 12:26 PM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: