1 Reply Latest reply on Sep 15, 2006 7:05 AM by Matlus

    can we use xml data outside of the Event Handler?

      Using the bellow code, how can I find out from loadXML function when the onComplete is completed and the xml data is available for use outside of onComplete method.

      public function loadXML():void
      var loader:URLLoader = new URLLoader();
      var request:URLRequest = new URLRequest("sportOne.xml");
      loader.addEventListener(Event.COMPLETE, onComplete);
      public function onComplete(event:Event):void
      text = "";
      var loader:URLLoader = URLLoader(event.target);
      scoresXML = new XML(loader.data);
        • 1. Re: can we use xml data outside of the Event Handler?
          Matlus Level 1
          I'm assuming you're trying to decouple your code such that the class the "uses" the xml is different from the class that loads the xml?

          If so:
          You can dispatch your own event when that happens so other classes can then suscribe to that event.

          Or you can simply pass in the callback function to be called after the xml has been loaded. In this case you will need to use the HttpService class since you get access to the Async token that essentially allows you to pass in addtional information that is accessible to you in the "called back" method.