3 Replies Latest reply on Aug 13, 2010 4:24 PM by Alex6377y

    UpdaterUI does not work when using isNewerVersionFunction

    stevetx2 Level 1

      When using isNewerVersionFunction in  Air 2..02  and 2.0.3  the Update screen appears  very shortly and then closes.

      When reverting back to Air 1.5.0.7220 it works fine

       

       

      private var appUpdater:ApplicationUpdaterUI;


      private var _host:String = new String;

       


      private function checkForUpdate():void {
      appUpdater = null;

      appUpdater = new ApplicationUpdaterUI();

      // Server-side XML file describing update

      appUpdater.updateURL = "http://" + _host + "/FlexBuild/" + xmlUpdateFile;

       

      setApplicationVersion();

      appUpdater.isNewerVersionFunction = customUpdaterVersions;

      appUpdater.isCheckForUpdateVisible = false;

      appUpdater.addEventListener(UpdateEvent.INITIALIZED,onUpdate);

      appUpdater.addEventListener(ErrorEvent.ERROR,onError);

      appUpdater.addEventListener(StatusUpdateEvent.UPDATE_STATUS,appVersions);

      appUpdater.initialize();

      }


      private function onError(event:ErrorEvent):void {

      Alert.show(event.toString());

      this.maximize();

      }


      private function onUpdate(event:UpdateEvent):void {

      appUpdater.checkNow(); // Go check for an update now


      }

       


      private function customUpdaterVersions(currentVersion:String,updateVersion:String):Boolean {

      try{

      log.info("server version "+Utilities.trim(Properties.getString("VERSION"))+ ", Appversion"+Utilities.trim(version));

      if (Utilities.trim(Properties.getString("VERSION")) != Utilities.trim(version)) {

      return true;

      }


      }catch(e:Error){

      log.fatal("ERROR IN customUpdaterVersions"+ e.toString());

      log.fatal("STACK Trace"+e.getStackTrace());

       

      }


      return false;

      }


       

      private function appVersions(evt:StatusUpdateEvent):void {

      var serverVer:String = Utilities.trim(evt.version);

      var clientVersion:String = Utilities.trim(evt.currentTarget.currentVersion);

      log.info("Cleint Application Version Number: " + clientVersion);

      log.info("Cleint XML Application Version Number From Server: " + serverVer);

      //log.info("appUpdater information "+ ObjectUtil.toString(appUpdater));


      }