Purpose
AirSimpleUpdater uses Adobe AIR's Updater class to help you build self-updating AIR apps with just a few lines of extra code:
<script type="text/javascript" src="updater-1.0.js"></script> <script> var myUpdater = new AirSimpleUpdater( 'http://www.example.com/air/application.xml', 'http://www.example.com/air/MyUpdateableAirApp-%version%.air' ); myUpdater.run(); </script>
Getting started
To use AirSimpleUpdater, you need to keep two files on your web server: The latest AIR installer archive for your application, and a copy of its application.xml file.
When you release a new version, simply overwrite the application.xml file and upload the new AIR installer archive. If the filename of your AIR file changes with each version (it contains the version number), then include %version% in your URL (optional).
If the code snippet in the first section is enough of an introduction for you, download updater-1.0.js to get started.
Or, you can download the sample application code and poke around.
To see AirSimpleUpdater in action, install version 1.0 of the sample application. After launching the application, you will be able to "auto-update" to version 1.1.
If you run into any trouble or have any feedback please email me.
Advanced usage
You may want to provide your own implementation for some of the functions in updater-1.0.js. For example:
myUpdater.noUpdateRequired = function()
{
alert("You already have the latest version! Congratulations!");
}Or:
myUpdater.whileWaiting = function(status)
{
switch (status)
{
case "CHECKING_FOR_UPDATE" :
statusText = "Checking for update, please wait...";
break;
case "DOWNLOADING_UPDATE" :
statusText = "Downloading update, please wait...";
break;
}
document.getElementById("status_update").innerHTML
= statusText;
}Some of the other functions you might want to customize:
| Function | Returns | Default behavior | Possible customized behavior |
| noUpdateRequired | Trigger normal program initialization | ||
| beforeUpdate | false to cancel update | Asks the user if they would like to update | Force the update |
| compareVersions | true if update required | Numerically compares version numbers | Compare using your own version numbering scheme |
| whileWaiting | Changes window title to update status | Show a customized status box | |
| finishedWaiting | Restores window title | Hide customized status box | |
| handleError | Displays error in an alert box | Show a customized error box |