AIR Update Checking Using Mate

While working on an AIR project hosted on Google Code I wanted to setup automatic updates. I wanted the entire project to be self contained and not require any supporting websites. After a little coding I can now use Mate and dispatch an event to check for updates.

Preparing for Updating

In the main mxml document I add a namespace for my ef-flex event maps (xmlns:efmaps="com.ef.air.maps.*") and the following line:

<!-- Automatic update event map -->
<efmaps:UpdateEventMap />

Once included, the Mate knows how to handle the update event and is listening for it. See the prosperonair main mxml for an example.

Automatic Update Checking

Using the event driven nature of Mate to check for an update–automatically or manually–is now as easy as dispatching an event. See the prosperonair event map for an example.

To automatically check for an update edit the application’s event map, add the import for the UpdateEvent, add an event handler for the AIREvent.WINDOW_COMPLETE event, and add the following (changed for your project):

<!-- Automatically check for newer version -->
<mate:EventAnnouncer generator="{UpdateEvent}" type="{UpdateEvent.CHECK}">
	<mate:Properties isAutomatic="true" versionURL="http://project.googlecode.com/svn/trunk/version.xml" />
</mate:EventAnnouncer>

Manual Update Checking

The process for checking for an update manually is almost identical to the automatic update check save for changing the isAutomatic property to false. This lets the updater know that the user should be notified when there is no update.

Version XML File

For the updater to work correctly you will need to have a XML file in your repository that the application will use to check if it has the latest version. You can read more about the format the xml file needs to use in the official documentation for the ApplicationUpdaterUI. Be sure that you pass the correct url of the XML file when doing an update check.

The Code

The code used in this post is available in the prosperonair and ef-flex projects. The main code of interest that performs the update can be seen in the UpdateManager.as file.

Add Your Comments

Required
Required
Tips

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <ol> <ul> <li> <strong>

Your email is never published nor shared.

Ready?