1 Reply Latest reply on Apr 12, 2010 4:26 AM by chrisdennett42

    air updater for flash


      i have an air app that i put some updater code into and i keep getting 1 of 2 errors.
      When i test the app in Flash i get Error ID: 404. Invalid HTTP status code: 404

      when i install the application and run it i get Error ID: 2032. Error #2032

      the error windows are the windows that are written into the code to come up so i know that part of the code is working. Any ideas or similar experiences?

      import air.update.ApplicationUpdater;
      import air.update.events.StatusFileUpdateEvent;
      import air.update.events.StatusUpdateErrorEvent;
      import air.update.events.StatusFileUpdateErrorEvent;
      import air.update.events.DownloadErrorEvent;
      import air.update.events.StatusUpdateEvent;
      import air.update.events.UpdateEvent;
      import flash.events.ErrorEvent;
      import flash.events.MouseEvent;
      import flash.desktop.NativeApplication;
      import flash.display.NativeWindow;
      import flash.display.NativeWindowInitOptions;
      import flash.display.NativeWindowSystemChrome;
      import flash.display.NativeWindowType;
      import flash.display.StageScaleMode;
      import flash.display.StageAlign;
      import fl.controls.Button;
      import Namespace;
      import XML;

      var appUpdater:ApplicationUpdater = new ApplicationUpdater();
      var window:NativeWindow;
      var windowContent:myWindow = new myWindow();
      var existentListenersictionary = new Dictionary();

      //initialize the updater; gets called when the application is loaded
      function initializeUpdater():void {
      appUpdater.updateURL = "http://www.mysite.com/myapp/updater/update.xml"; <-----this xml file has a url tag pointing to the new .air file
      //we set the event handlers for INITIALIZED nad ERROR

      appUpdater.addEventListener(UpdateEvent.INITIALIZE  D, onUpdate);
      appUpdater.addEventListener(ErrorEvent.ERROR, onError);

      appUpdater.addEventListener(StatusUpdateEvent.UPDA  TE_STATUS, onStatusUpdate);
      appUpdater.addEventListener(StatusUpdateErrorEvent  .UPDATE_ERROR, onStatusUpdateError);

      appUpdater.addEventListener(ProgressEvent.PROGRESS  , onDownloadProgress);

      appUpdater.addEventListener(UpdateEvent.DOWNLOAD_C  OMPLETE, onDownloadComplete);
      appUpdater.addEventListener(DownloadErrorEvent.DOW  NLOAD_ERROR, onDownloadError);
      //initialize the updater
      //listener for INITIALIZED event of the applicationUpdater;
      function onUpdate(event:UpdateEvent):void {
      //start the process of checking for a new update and to install
      //Handler function for error events triggered by the ApplicationUpdater.initialize
      function onError(event:ErrorEvent):void {
      displayWindowError(event.errorID, event.text);
      //handler function for StatusUpdateEvent.UPDATE_STATUS
      //this is called after the update descriptor was downloaded and interpreted successfuly
      function onStatusUpdate(event:StatusUpdateEvent):void {
      //prevent the default (start downloading the new version)
      windowContent.bar.visible = false; //hide the progress bar
      //create the window for displaying Update available
      if (event.available) {
      windowContent.title = "Update Available";
      windowContent.enableDescription = true;
      windowContent.description = event.version + " " + event.details[0][1];
      windowContent.buttonLeft.label = "Update";
      windowContent.buttonRight.label = "Cancel";
      addEventToButton(windowContent.buttonLeft, MouseEvent.CLICK, startDownload);
      addEventToButton(windowContent.buttonRight, MouseEvent.CLICK, closeWindow);
      //we don't have an update, so display this information
      } else {
      windowContent.title = "No Update Available";
      windowContent.enableDescription = false;
      windowContent.buttonLeft.visible = false;
      windowContent.buttonRight.label = "Close";
      addEventToButton(windowContent.buttonRight, MouseEvent.CLICK, closeWindow);
      //error listener for an error when the updater could not download or
      //interpret the update descriptor file.
      function onStatusUpdateError(event:StatusUpdateErrorEvent):  void
      displayWindowError(event.subErrorID, event.text);
      //error listener for DownloadErrorEvent. Dispatched if there is an error while connecting or
      //downloading the update file. It is also dispatched for invalid HTTP statuses
      //(such as "404 - File not found").
      function onDownloadError(eventownloadErrorEvent):void {
      displayWindowError(event.subErrorID, event.text);   
      //start the download of the new version
      function startDownload(event:MouseEvent):void {
      windowContent.bar.visible = true;
      windowContent.bar.setProgress(0, 100);
      //listener for the ProgressEvent when a download of the new version is in progress
      function onDownloadProgress(event:ProgressEvent):void {
      windowContent.bar.setProgress(event.bytesLoaded, event.bytesTotal);
      //listener for the complete event for downloading the application
      //just close the window; the downloaded version will be automatically installed,
      //and then the application gets restarted
      function onDownloadComplete(event:UpdateEvent):void {
      //sets the state of the window in error display mode
      function displayWindowError(errorId:int, errorText:String):void
      windowContent.title = "Error";
      windowContent.enableDescription = true;
      windowContent.description = "Error ID: " + errorId + ". " + errorText;
      windowContent.buttonLeft.visible = false;
      windowContent.buttonRight.label = "Close";
      windowContent.bar.visible = false;
      addEventToButton(windowContent.buttonRight, MouseEvent.CLICK, closeWindow);
      //create a window using NativeWindow, and as a content myWindow class
      function createWindow():void {
      if (window == null) {
      var options:NativeWindowInitOptions = new NativeWindowInitOptions();
      options.systemChrome = NativeWindowSystemChrome.STANDARD;
      options.type = NativeWindowType.NORMAL;

      window = new NativeWindow(options);
      window.x = 830;
      window.y = 550;
      window.stage.stageHeight = 196;
      window.stage.stageWidth = 400;
      window.stage.scaleMode = StageScaleMode.NO_SCALE;
      window.stage.align = StageAlign.TOP_LEFT;
      windowContent.bar.visible = false;
      window.alwaysInFront = true;
      window.visible = true;
      //close the window
      function closeWindow(event:Event):void {
      //hide the window
      function hideWindow():void {
      window.visible = false;
      //sets the application name and version in the main window
      function setApplicationNameAndVersion():void {
      var appXML:XML = NativeApplication.nativeApplication.applicationDes  criptor;
      var ns:Namespace = appXML.namespace();
      lblVersion.text = appXML.ns::version;
      lblName.text = appXML.ns::name;
      //add to the given button, the listener for given type (actually we use only the type MouseEvent.CLICK).
      //we use a dictionary to store for each button the listener registered.
      //when this function gets called, first we remove any registered listener. Next we register the listener
      //on the button, and next we save to dictionary.
      function addEventToButton(button:Button, type:String, listener:Function):void
      //remove existent listneres
      if (existentListeners[button] != null) {
      var arr:Array = existentListeners[button] as Array;
      button.removeEventListener(type, arr[0]);
      existentListeners[button] = [];
      button.addEventListener(type, listener);
      existentListeners[button][0] = listener;
      button.visible = true;

      //initialize the updater

        • 1. Re: air updater for flash

          Hello hjames28,


          I just had a similar problem and for me the problem wasn't in the actionscript, but in the update.xml file.

          I'd made an error in the <url> bit for the .air file on my site (it had an extra "http:" at the front if you must know!).


          Your problem may well be different and since your post was quite a while ago, you've probably fixed it.  This will be a handy reminder at least to myself when I inevitably forget all this and google the same problem in the future.


          If a future me does find this... "Hello future me, I see your documentation is still no better!"