2 Replies Latest reply on Jun 28, 2010 9:10 AM by The_Chef

    My Flash Air update function wont work. PLEASE PLEASE HELP.

    The_Chef

      I need to make my Air application that I made in Flash check for an update when the user runs it - if available it will download/install. I have been trying to make this work for several days and I cant get it to work at all.

       

      I made the most basic Flash movie to test it. A single frame with "Hello" typed in the window and the ActionScript on that fram is as follows:

       

      var urlString:String = "http://www.mysite.com/clients/example/Update/Airmovie_v2.air";
      var urlReq:URLRequest = new URLRequest(urlString);
      var urlStream:URLStream = new URLStream();
      var fileData:ByteArray = new ByteArray();
      urlStream.addEventListener(Event.COMPLETE, loaded);
      urlStream.load(urlReq);

      function loaded(event:Event):void {
          urlStream.readBytes(fileData, 0, urlStream.bytesAvailable);
          writeAirFile();
      }

      function writeAirFile():void {
          var file:File = File.applicationStorageDirectory.resolvePath("Airmovie_v2.air");
          var fileStream:FileStream = new FileStream();
          fileStream.open(file, FileMode.WRITE);
          fileStream.writeBytes(fileData, 0, fileData.length);
          fileStream.close();
          trace("The AIR file is written.");
      }

       

      var updater:Updater = new Updater();
      var airFile:File = File.desktopDirectory.resolvePath("Airmovie_v2.air");
      var version:String = "2.01";
      updater.update(airFile, version);

       

      I got this code from this Adobe site.

       

      When create the Air file from CS5 and install it - I get this message:

      "Sorry, an error has occured.

      The application could not be installed because the installer file is damaged. Try obtaining a new installer file from the application author."

       

      The client is getting so impatient with me and I am out of ideas. Please, any help would be so appreciated.