« Apollo ActionScript / JavaScript Bridge | Main | Indy Flex User Group Tonight »
Apollo Self Updating Applications
Print This PostOne of the beauties of Apollo is the ability of the application to update itself whenever necessary. Those of us who are used to the client/server metaphor have never had to worry about this because if we found a bug in our code (yeah right), we could simply update the server and it is like it never even happened. However, now that we are offering our applications for download, we lose a certain piece of control. Unless, we build in a method for our applications to update themselves when necessary.
This example shows one method for doing this. Here is how it works.
2
3
<latestVersion>.4</latestVersion>
<latestFileName>SelfUpdating04.air</latestFileName>
Here are some screen shots and links to download the outdated version of the application and source code.
Version .3 loads:

User clicks “Check for Update”

After choosing “Yes” new version downloads and installs (Wow what an upgrade!!)

Finally, the user clicks “Check for Updates” again

NOTE: Please do not run this over and over again or you will suck up all of my bandwidth. You can easily replicate this on your own servers. ![]()
Also, this application puts the control in the users hands, but you can also do all of this automatically by checking the version on creationComplete and then installing the new version automatically without user interaction.
Share this Post
Topics: Adobe AIR, Tutorials |


![[image]](http://mowser.com/img?url=http%3A%2F%2Fassets.max.adobe.com%2Fimages%2FMAX09_D125x125.jpg)




March 20th, 2007 at 12:14 pm
I’ve got a solution similar to this, but I’ve also integrated online/offline notification in to this. When the app pings my server to check if it’s online/offline, it also checks the version and updates if necessary.
March 20th, 2007 at 12:25 pm
Very cool.
Thanks for your comments.
March 21st, 2007 at 6:59 pm
Very cool indeed!
One caveat though - if you move the application from the default installation folder (~/Applications on Mac OS X) into another folder the update will fail. The updated application will be installed in the default location, and the “old” application will then be relaunched - making it appear that it hasn’t updated at all - and leaving you with two different versions of the same application in two different locations!
April 22nd, 2007 at 9:06 pm
Hey, the download links aren’t working, I was really looking forward to seeing the code for this,
Please send me an email if you fix it!
April 22nd, 2007 at 9:08 pm
The link has bad case, it links to “Apollo”, when it should be “apollo”
Thanks!
April 22nd, 2007 at 10:12 pm
Sorry, I recently switched to a Linux box. It is fixed now.
June 15th, 2007 at 2:12 pm
It would be really awesome if there was an example of a self-updating HTML based AIR app? I’m building AIR apps using HTML/JS and would really like to take advantage of the same update feature.
July 14th, 2007 at 3:55 am
Might you be updating your source code for the AIR beta? I try including your source code in my app and when I try & run it in Flex 3 Beta, I get an error of this:
1136: Incorrect number of arguments. Expected 2.
It’s talking about the last line in this section:
// Handle CLOSE Event when file write has completed and call update to update application install
private function fileClosed(event:Event):void {
var updater:Updater = new Updater();
var airFile:File = File.desktopDirectory.resolve(this.latestFileName);
The line causing the error –> updater.update(airFile);
If you could at least suggest to me how to fix it, that be awesome as I could really use this in my app.
July 14th, 2007 at 7:28 am
I will when I get a chance. In the mean time you can check out this site:
http://merhl.com/?p=32
October 6th, 2007 at 3:33 am
Thanks for the article.I just got an idea of using this feature for my applications.There are many things which should be taken care of before updating an application.
thanks,it looks every body is now thinking for self updating application.
October 6th, 2007 at 6:59 am
Take a look at my newer version at:
http://blog.everythingflex.com/2007/10/01/air-update-manager/
April 28th, 2008 at 7:42 am
cann’t use for 1.1
April 28th, 2008 at 8:41 am
No, this was Apollo code. Check here for AIR code:
http://blog.everythingflex.com/air-central/everythingflexair1swc/updatemanager/
April 28th, 2008 at 9:18 am
hello everythingflex~
think u for your answer.
when i use your swc,
there is a error:
1120: 访问的属性 um 未定义。
so bizarrerie~~
my code:
import com.everythingflex.air.managers.UpdateManager;
private var um:UpdateManager = new UpdateManager(”http://……./prototype/version.xml”,true);
um.currentVersion=”.2″;
April 28th, 2008 at 9:28 am
if i don’t use the currentVersion property,
it can check & download the new version,
but when installing, a error occur:
This application cannot be installed because this installer has been mis-configured. Please contact the application author for assistance.