1 Reply Latest reply on Feb 1, 2009 9:42 PM by Gregory Lafrance

    Getting Status of HTTPService request

    miglara
      Hi,
      Do you know if there is a way to force the business logic to wait until we've gotten all the data from an HTTPService request? That is, a condition that checks if the status of the HTTPService.send() command has been completed.

      Here is some code to explain the problem we're having:

      <mx:HTTPService id="feedbackService" url="model/feedback.xml" result="feedbackHandler(event)" />

      [Bindable]
      public var feedbackAC:ArrayCollection=new ArrayCollection()

      public function feedbackHandler(evnt:ResultEvent):void{
      feedbackAC = evnt.result.feedbackRecord.feedback;
      Alert.show(feedbackAC[0].message); //This works fine, the right value is displayed ok
      }

      public function getFeedbackRecord(feedbackId:String):void{
      feedbackService.cancel();
      var params:Object = new Object();
      params.feedbackId = feedbackId;
      feedbackService.send(params);
      }

      public function selectFeedback():void{
      //this method has a "switch" statement that selects the feedbackId to be retrieve from the database
      getFeedbackRecord("101"); //for sample sake, let's suppose we're just retrieving record 101.
      Alert.show(feedbackAC[0].message); // Here is the problem! This value is NULL even though the right
      //message was already displayed in the handler function!
      }

      Any idea or suggestion will be GREATLY appreciated!!

      Thank you!

      Miguel