Skip to main content
Inspiring
August 12, 2011
Question

AIR Remote Updater

  • August 12, 2011
  • 1 reply
  • 713 views

Hi all,

I found a very useful AIR remote updater http://codeazur.com.br/lab/airremoteupdater/ written by Claus Wahlers. It works fine but I have a question which I myself can't figure it out.

Just a newbie in flash I guess.

Question:

What if the script can't find  yourapplication.air inside my domain.com host?

What will happen?

I have tested it out. It appears that the script keep on running to find yourapplication.air inside my server. But it is not there. How do I make a timeout when if there is no such "yourapplication.air" file in the server / it will skip the update process?

public function update():void {
   var request:URLRequest = new URLRequest("http://domain.com/yourapplication.air");
   var updater:AIRRemoteUpdater = new AIRRemoteUpdater();
   updater.addEventListener(AIRRemoteUpdaterEvent.VERSION_CHECK, updaterVersionCheckHandler);
   updater.addEventListener(AIRRemoteUpdaterEvent.UPDATE, updaterUpdateHandler);
   updater.update(request);
}
 
protected function updaterVersionCheckHandler(event:AIRRemoteUpdaterEvent):void {
   // The AIRRemoteUpdaterEvent.VERSION_CHECK event is fired
   // as soon as both local and remote version numbers are known. 
   var updater:AIRRemoteUpdater = event.target as AIRRemoteUpdater;
   trace("Local version: " + updater.localVersion);
   trace("Remote version: " + updater.remoteVersion);
   // You can stop execution of AIR Remote Updater at this point 
   // by calling event.preventDefault(), for example to inform the user 
   // that a new version is available and/or ask if she likes to download 
   // and install it. When the user confirms, call AIRRemoteUpdater.update()
   // again with the versionCheck argument set to "false". This will
   // circumvent the version checking procedure and immediately
   // starts to download the remote .AIR installer file to a temporary
   // file on the user's harddisk.
}
 
protected function updaterUpdateHandler(event:AIRRemoteUpdaterEvent):void {
   // The AIRRemoteUpdaterEvent.UPDATE event is fired when
   // the remote .AIR installer file has finished downloading.
   // The event's "file" property contains a reference to the
   // temporary file on the user's harddisk.
   trace("Installer: " + event.file.nativePath);
   // You can stop execution of AIR Remote Updater at this point 
   // by calling event.preventDefault(), for example to inform the user 
   // that the application is about to shut down and update itself.
}

This topic has been closed for replies.

1 reply

Kenneth Kawamoto
Community Expert
Community Expert
August 12, 2011

> What if the script can't find  yourapplication.air inside my domain.com host?

Unless you have the AIR in the server you cannot do the online update!

ZainuuAuthor
Inspiring
August 12, 2011

Yes you are right! But I'm trying to ask how do I do a "skip update" if my AIR is not in the server?

Because the source code does not skip updating if AIR is not found in server. It just keep searching for the AIR file forever.... So how can I write a code to excute (to skip the update process and proceed with my application) a skip update?

Kenneth Kawamoto
Community Expert
Community Expert
August 12, 2011

One way is to use URLLoader class to load the AIR file and listen to events. For example if you encounter the ioError event abort the update process, and if you receive open event close the URLLoader and proceed to the update process.