7 Replies Latest reply on Nov 30, 2007 12:35 PM by weeijj

    add event listener to HTTPService call

    ljonny18 Level 1
      Hi – I am using a HTTP service within my flex application.
      My HTTPServeice is connecting to an XML file:


      <mx:HTTPService
      id="myResults"
      url=" http://localhost/myResults.xml"
      resultFormat="e4x"
      result="resultHandler(event)" />

      the data within the XML file is constantly changing (the structure remains the same, but the actual data within the structure of the XML changes), therefore I am refreshing my HTTPService results every 5 seconds:

      [Bindable]
      public var myDataFeed:XML;

      private function initApp():void
      {
      var timedProcess:uint = setInterval(refreshResults, 5000);
      }

      private function refreshResults():void
      {
      myResults.send();
      }

      private function resultHandler(event:ResultEvent):void
      {
      myDataFeed = event.result as XML;
      }


      My problem is that sometimes the XML file needs longer than 5 seconds to load / refresh the data (as it is quite heavy) etc… therefore I want to implement some sort of event listener on the HTTPService to let the application know when the results have been refreshed so I can restrict / the 5 second refresh taking place until the previos refresh is complete etc…

      is this possible – to set an event listener to a HTTPService to know when it has completed refreshing results from an XML file???

      Thanks,
      Jon.