0 Replies Latest reply on Aug 19, 2009 12:59 PM by varun.maddy

    AIR Auto update error

    varun.maddy

      Hello all,

       

      I am trying to build an autoupdate app in AIR using FB4. I use the code :

       

      import flash.system.System;
              import flash.events.ErrorEvent;
              import air.update.ApplicationUpdaterUI;
              import air.update.events.UpdateEvent;
            
             
              [Bindable]
              private var appUpdater:ApplicationUpdaterUI = new ApplicationUpdaterUI();

       

      protected function checkForUpdate():void {
               
                  NativeApplication.nativeApplication.addEventListener( Event.EXITING,
                      function(e:Event):void {
                          var opened:Array = NativeApplication.nativeApplication.openedWindows;
                          for (var i:int = 0; i < opened.length; i ++) {
                              opened[i].close();
                          }
                      });   
             
                  setApplicationVersion();
                 
              
                  appUpdater.updateURL = "http://localhost/updateTest/update.xml";
                  appUpdater.isCheckForUpdateVisible = false;
                  appUpdater.addEventListener(UpdateEvent.INITIALIZED, onUpdate);
                  appUpdater.addEventListener(ErrorEvent.ERROR, onError);
                  appUpdater.initialize();
              }
             
              protected function onError(event:ErrorEvent):void {
                  Alert.show(event.toString());
              }
             
              protected function onUpdate(event:UpdateEvent):void {
                  appUpdater.checkNow();
              }
             
           
              protected function setApplicationVersion():void {
                  var appXML:XML = NativeApplication.nativeApplication.applicationDescriptor;
                  var ns:Namespace = appXML.namespace();
                  ver.text = "Current version is " + appXML.ns::version;
              }

       

       

      whats wrong in the above code.... when the checkForUpdate function initiated an error occured :

       

      TypeError: Error #1007: Instantiation attempted on a non-constructor.
          at mx.controls::ProgressBar/createChildren()
          at mx.core::UIComponent/initialize()[E:\dev\beta1\frameworks\projects\framework\src\mx\core\ UIComponent.as:6510]
          at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\beta1\frameworks\projects\ framework\src\mx\core\UIComponent.as:6402]
          at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\beta1\frameworks\projects\ framework\src\mx\core\Container.as:3879]
          at mx.core::Container/addChildAt()[E:\dev\beta1\frameworks\projects\framework\src\mx\core\Co ntainer.as:2541]
          at mx.core::Container/addChild()[E:\dev\beta1\frameworks\projects\framework\src\mx\core\Cont ainer.as:2459]
          at ApplicationUpdaterDialogs/_ApplicationUpdaterDialogs_ApplicationUpdaterVBox10_c()
          at mx.core::DeferredInstanceFromFunction/getInstance()[E:\dev\beta1\frameworks\projects\fram ework\src\mx\core\DeferredInstanceFromFunction.as:105]
          at mx.states::AddChild/createInstance()
          at mx.states::AddChild/set targetFactory()
          at ApplicationUpdaterDialogs/_ApplicationUpdaterDialogs_AddChild8_i()
          at ApplicationUpdaterDialogs/_ApplicationUpdaterDialogs_State7_c()
          at ApplicationUpdaterDialogs()
          at _ApplicationUpdaterDialogs_mx_managers_SystemManager/create()
          at mx.managers::SystemManager/initializeTopLevelWindow()[E:\dev\beta1\frameworks\projects\fr amework\src\mx\managers\SystemManager.as:3581]
          at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::docFrameHandler()[E:\dev\beta1\frameworks\proj ects\framework\src\mx\managers\SystemManager.as:3400]
          at mx.managers::SystemManager/docFrameListener()[E:\dev\beta1\frameworks\projects\framework\ src\mx\managers\SystemManager.as:3258]