2 Replies Latest reply on Sep 20, 2010 4:45 AM by Alex-Wright

    HTTPService & ResultEvent Execution Order

    Alex-Wright

      Hi,

       

      I have a function that I call to get data using an HTTPService, which has an eventlistener, which calls another function to handle the data the service recieves.

       

      I would like to have my function containing the service returning a boolean value based on whether data has loaded the service. Something like:

       

       

       

       

              public function serviceFunction():Boolean 
              {
                  ...
                  service.addEventListener(ResultEvent.RESULT, dataFunction);
                  ...
                  service.send();
                  return this.loaded;
                  
              }          
      
              private function dataFunction(e:ResultEvent):void 
              {
                      if(e.result.data == loaded) {
                          this.loaded= true;                    
                      } else {
                          this.loaded= false;                    
                      }
      
                  }
      

       

       

      When doing it this way, I find that the return statement is executed before the code within the data function.

       

      Is there a way of being able to return the updated boolean in the first function?

       

      Thanks,

       

        Alex.