O'Reilly logo

Beginning Adobe® AIR™: Building Applications for the Adobe Integrated Runtime by Rich Tretola

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A.10. Make It Self-Updating

Another issue that was a non-issue when this was a Flex Web-based application is version control. Back then, if we wanted to push out a new version, we would simply upload the changes to the server, and on the next visit the user would get the new version. With an AIR application, our users are not visiting our server on each run of the application, so we could easily lose control over our application. The solution to this is to program a self-updating scheme. It is very important that you implement this on the first version you release or you will wind up with applications that are orphans with no chance of being updated unless the user actively requests the update. Note that this solution is one that I created and is not an official Adobe method for doing application updates.

Please follow these steps to add self-updating to the WeatherAIR application.

Create a new ActionScript class named UpdateManager within the com.everthingflex.air.managers package, and enter the contents of Listing A-5 into this new class.

Example A-5. The UpdateManager class
package com.everythingflex.air.managers
{
    import flash.desktop.NativeApplication;
    import flash.desktop.Updater;
import  flash.events.Event;
    import  flash.filesystem.File;
    import  flash.filesystem.FileMode;
    import  flash.filesystem.FileStream;
    import  flash.net.URLRequest;
    import  flash.net.URLStream;
    import  flash.utils.ByteArray;

    import  mx.controls.Alert;
    import  mx.events.CloseEvent;
    import  mx.rpc.events.FaultEvent; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required