Archive for the ‘NAU’ tag
ADC tutorial: Updating Adobe AIR applications packaged with a native installer
My tutorial about updating AIR apps packaged with a native installer was published on Adobe Developer Connection – it is available here.
It goes step-by-step through how a custom updater can be built for Windows; it also explains how a similar process could be applied for the Mac OS X platform.
This tutorial is also a good starting point to understand how my NativeApplicationUpdater library works.
NativeApplicationUpdater 0.5.0 released
Today I published a new version (0.5.0) of the NativeApplicationUpdater library to the Google Code project.
- Configuring proper XML settings when parsing plist in the HdiutilHelper class (based on contribution from a Erik Pettersson)
- The update file is downloaded into a temporary folder with its name parsed out of the download url
- If cmd.exe is found it is used to run the update file (based on the contribution from Jeff Pace)
You can also find out more about NativeApplicationUpdater here.
Building NativeApplicationUpdater custom UI
After I published the NativeApplicationUpdater library I received a lot of questions how to display a UI showing download and install progress. Unfortunately NAU doesn’t come with a built-in UI yet
So I decided to put together this short blog post to explain how you can build it yourself. Below you can see how the demo app with the custom UI looks (project source code is available here in SVN):

Below is snippet of code that you can examine to better understand how to build your own updater UI:
<?xml version="1.0" encoding="utf-8"?> <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:updater="http://updater.riaspace.com/"> <fx:Script> <![CDATA[ import air.update.events.DownloadErrorEvent; import air.update.events.StatusUpdateEvent; import air.update.events.UpdateEvent; import mx.controls.Alert; [Bindable] protected var downlaoding:Boolean = false; protected function isNewerFunction(currentVersion:String, updateVersion:String):Boolean { // Example of custom isNewerFunction function, it can be omitted if one doesn't want // to implement it's own version comparison logic. Be default it does simple string // comparison. return true; } protected function updater_errorHandler(event:ErrorEvent):void { Alert.show(event.text); } protected function btnCheckNow_clickHandler(event:MouseEvent):void { // First initialize NativeApplicationUpdater updater.initialize(); } protected function updater_initializedHandler(event:UpdateEvent):void { // When NativeApplicationUpdater is initialized you can call checkNow function updater.checkNow(); } protected function updater_updateStatusHandler(event:StatusUpdateEvent):void { if (event.available) { // In case update is available prevent default behavior of checkNow() function // and switch to the view that gives the user ability to decide if he wants to // install new version of the application. event.preventDefault(); currentState = "updaterView"; } else { Alert.show("Your application is up to date!"); } } protected function btnYes_clickHandler(event:MouseEvent):void { // In case user wants to download and install update display download progress bar // and invoke downloadUpdate() function. downlaoding = true; updater.addEventListener(DownloadErrorEvent.DOWNLOAD_ERROR, updater_downloadErrorHandler); updater.addEventListener(UpdateEvent.DOWNLOAD_COMPLETE, updater_downloadCompleteHandler); updater.downloadUpdate(); } protected function btnNo_clickHandler(event:MouseEvent):void { currentState = "mainView"; } private function updater_downloadCompleteHandler(event:UpdateEvent):void { // When update is downloaded install it. updater.installUpdate(); } private function updater_downloadErrorHandler(event:DownloadErrorEvent):void { Alert.show("Error downloading update file, try again later."); } ]]> </fx:Script> <s:states> <s:State name="mainView"/> <s:State name="updaterView"/> </s:states> <fx:Declarations> <updater:NativeApplicationUpdater id="updater" updateURL="http://riaspace.com/native-application-updater/update-1.1.xml" isNewerVersionFunction="{isNewerFunction}" initialized="updater_initializedHandler(event)" updateStatus="updater_updateStatusHandler(event)" error="updater_errorHandler(event)" downloadError="updater_errorHandler(event)" updateError="updater_errorHandler(event)" /> </fx:Declarations> <s:Button id="btnCheckNow" label="Check for updates" includeIn="mainView" horizontalCenter="0" verticalCenter="0" click="btnCheckNow_clickHandler(event)"/> <s:HGroup verticalCenter="0" includeIn="updaterView" horizontalCenter="0" verticalAlign="top"> <s:BitmapImage source="@Embed(source='/assets/icon128.png')" /> <s:VGroup width="100%" horizontalAlign="center"> <s:Label text="New version ({updater.updateVersion}) is available." /> <s:Label text="Do you want to download it and install?" /> <mx:ProgressBar id="prgBar" source="{updater}" label="Downloading %3%" visible="{downlaoding}" /> <s:HGroup> <s:Button id="btnYes" label="Yes" click="btnYes_clickHandler(event)" /> <s:Button id="btnNo" label="No" click="btnNo_clickHandler(event)" /> </s:HGroup> </s:VGroup> </s:HGroup> </s:WindowedApplication>
NativeApplicationUpdater version 0.4 released!
I just posted a new version (0.4) of the NativeApplicationUpdater library. It fixes some minor bugs and removes a workaround for the different URLStream events sequence between Win OS and other OSes.
Stay tuned for my next post that explains how to build NAU custom UI.
NativeApplicationUpdater – updater for AIR apps packaged with native installers
I just released on Google Code a new project called NativeApplicationUpdater. Basically the name explains its purpose but for those that don’t know, AIR 2.0 brings new capability of packaging applications with native installers. This is necessary when you want to use the new NativeProcess APIs. Unfortunately Update Framework that comes with AIR 2.0 SDK doesn’t bring yet capability of updating this type of applications. That is why I decided to build it myself and publish it as open source library.
Here is a video explaining how it works:

