ACE

Calendar

March 2007
S M T W T F S
  1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Tag Cloud

360Flex actionscript air android apple as3 books conference contest cookbook deeplinking FileReference flash flash builder flash catalyst Flash Player flashplayer flashplayer10 Flex flex4 flexbuilder flickr fotobooth Frameworks google gumbo ImageDropR indexing InsideRIA iphone java localconnection max merapi microsoft mobile pixel bender riatrax SilverLight sqlite swf Thermo update framework updatemanager URLTestr

Categories

Archives

Recent Posts

Recent Comments


« Apollo ActionScript / JavaScript Bridge | Main | Indy Flex User Group Tonight »

Apollo Self Updating Applications

By Rich Tretola | March 20, 2007 Print This Post Print This Post
2,414 views

One 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.

I set a variable to hold the current version number (It would be nice if we could simply read the version number from the -app.xml file but I don’t see a way to easily do this with the current alpha) I have setup an xml file on my server to store the latest version number and file name which is called via HTTPService. Here is what the XML file looks like:
1
2
3
<?xml version=â€1.0″ encoding=â€ISO-8859-1″?>
<latestVersion>.4</latestVersion>
<latestFileName>SelfUpdating04.air</latestFileName>
After calling the HTTPService, I compare the currentVersion to the latestVersion and Alert the user. If the user asks for the update I retrieve it via the URLSteam, which then calls methods to write the AIR file to disk. Finally, I call the Updater update method which installs the new version and restarts the application.

Here are some screen shots and links to download the outdated version of the application and source code.

Version .3 loads:

selfupdating1.jpg

User clicks “Check for Update”

selfupdating2.jpg

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

selfupdating3.jpg

Finally, the user clicks “Check for Updates” again

selfupdating4.jpg

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.

Download the Application

Download the Source Code

Share this Post


Topics: Adobe AIR, Tutorials |

15 Responses to “Apollo Self Updating Applications”

Alex MacCaw Says:
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.

everythingflex Says:
March 20th, 2007 at 12:25 pm

Very cool.

Thanks for your comments.

Nick Says:
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!

Dusty Says:
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!

Dusty Says:
April 22nd, 2007 at 9:08 pm

The link has bad case, it links to “Apollo”, when it should be “apollo”

Thanks!

everythingflex Says:
April 22nd, 2007 at 10:12 pm

Sorry, I recently switched to a Linux box. It is fixed now.

Andrew Wooldridge Says:
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.

Alex Brofsky Says:
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.

everythingflex Says:
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

Ashish Jha Says:
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.

everythingflex Says:
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/

å°å°èœé¸Ÿ Says:
April 28th, 2008 at 7:42 am

cann’t use for 1.1

everythingflex Says:
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/

å°å°èœé¸Ÿ Says:
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″;

å°å°èœé¸Ÿ Says:
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.

Comments



You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser
Mobilytics