8 Replies Latest reply on May 1, 2010 9:29 PM by rahal sanjaya

    Automatic updates

      Is it possible to make a running Adobe AIR application upgrade itself to a newer version and then restart itself when a new version of the application is available?
      I understand that Adobe AIR apps can check for new versions during start-up, but I want to check for new versions every 30'th minute, while the application is running. If a new version is available, I want to install it and upgrade to it without any user interaction.


      Also, the application runs on a computer with no keyboard and mouse, which is why I need the automatic upgrade and restart.


      / nitramk
        • 1. Re: Automatic updates
          Jeff Swartz Level 3

          Yes, it is possible to have the application check for an update at any time. If you are using the update framework, you can call the checkNow() method of the ApplicationUpdater or ApplicationUpdaterUI class.

          • 2. Re: Automatic updates
            nitramkn Level 1

            But is it possible to automatically restart the application (the new version) without any user intervention if this happens?

            Or does the user have to confirm that the new version should be installed / used?

            • 3. Re: Automatic updates
              ilsh Level 1

              Yes. You new application will be restarted automatically. For example, my application (not using Update framework), will automatically check if new version exist on server when it starts, if yes, then it will auto download  and install it, then restart the new version without any user intervention.

              • 4. Re: Automatic updates
                __antonio__ Level 3

                What environment are you building your AIR app in?

                • 5. Re: Automatic updates
                  __antonio__ Level 3

                  Be sure to read the following code carefully as urls are absolute and will need to be altered. (This is made with Flex 3.3 with AIR 1.5.2 but will work with earlier versions)


                  Main Application:

                  <?xml version="1.0" encoding="utf-8"?>
                  <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="checkForAppUpdate()">
                                 import air.update.events.UpdateEvent;
                                 import air.update.ApplicationUpdaterUI;
                                 private var appUpdater:ApplicationUpdaterUI = new ApplicationUpdaterUI;
                  // checks to see if an updated version of the app is up.
                                 private function checkForAppUpdate():void
                                      appUpdater.configurationFile = new File("app:/updateConfig.xml");
                                      appUpdater.isCheckForUpdateVisible = false;
                                      appUpdater.addEventListener(UpdateEvent.INITIALIZED, onUpdate);
                                      appUpdater.addEventListener(ErrorEvent.ERROR, onError);
                  // if there's an error to the update show an alert
                                 private function onError(event:ErrorEvent):void
                  // check to see if updated is needed
                                 private function onUpdate(event:UpdateEvent):void


                  updateConfig.xml (with your src, compiled at build):

                  <?xml version="1.0" encoding="utf-8"?>
                  <configuration xmlns="http://ns.adobe.com/air/framework/update/configuration/1.0">
                            <dialog name="checkForUpdate" visible="false" />
                            <dialog name="downloadUpdate" visible="false" />
                            <dialog name="downloadProgress" visible="false" />
                            <dialog name="installUpdate" visible="false" />
                            <dialog name="fileUpdate" visible="false" />
                            <dialog name="unexpectedError" visible="true" />

                  Delay is per day. .5 is half day, .02 = half an hour. In the <defaultUI> node, these <dialog>'s set to false makes updating invisible and without interaction, except Error.


                  appUpdate.xml (to be placed somewhere on your site):

                  <?xml version="1.0" encoding="utf-8"?>  
                       <update xmlns="http://ns.adobe.com/air/framework/update/description/1.0">  
                                 This is where your description goes.



                  Next time you make an update, change the version in both appUpdate and your application's descriptor file (the myApplication-app.xml) that resides in your src along side your application. Then repost your .air and appUpdate.xml files to the same respective places as your originals.

                  • 6. Re: Automatic updates
                    mroiler Level 1

                    I was taking a look at this and I got 2 errors. They were both at the line with appUpdater.configurationFile = new File(app:/data/updateConfig.xml); They were:

                         -1084: Syntax error:expecting rightparen before colon.

                         -1093: Syntax error.


                    I am running FlashBuilder 4.

                    • 7. Re: Automatic updates
                      mroiler Level 1

                      Never mind. took out app:/ and added quotes around the rest and it worked pefectly.

                      • 8. Re: Automatic updates
                        rahal sanjaya


                        i am using felx builder 3.0 and i cant import "air.update" library,it has only "air.net" library. why is that?