Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Waiting for a response from HTTPService

New Here ,
Aug 28, 2013 Aug 28, 2013

HI

I'm writing a procedure in flash builder 4.6.

To read the tables from the DB, use some functions in a script implemetate

  as, board using HTTPService.

When I make a call I would like that after the send (), actionscript

waiting for the return of the response, before moving to education

next.

how can you do?

my code:

<mx:Application ...>

.....

RestManager.executeGetRestMethod("conversation/start",null);  // Call HTTPService (RestManager.as)

....

RestManager.as

                    public static function executeGetRestMethod (servicePath:String, parameters:Object) {

                              executeRestMethod(servicePath, parameters, 'GET',responseHandler);    

                    }

               

        public static function executeRestMethod (servicePath:String, parameters:Object, httpMethod:String, handlerFunction:Function):void {

       

                           var restService:HTTPService = new HTTPService();

 

                              restService.method = httpMethod;

                              restService.url = getRestBaseUrl() + servicePath;

                              restService.addEventListener(ResultEvent.RESULT, handlerFunction);  // Function for decoding response

                              restService.addEventListener(FaultEvent.FAULT, errorHandler);

 

                              responseHandlerExecuted=false;

 

                              PhiLogger.log("REST Manager", "Operation: " + servicePath+ " ("+httpMethod+")", "Requested");

                              if (parameters != null)

                                        restService.send(parameters);

                              else

                                        restService.send();

 

        }

      

        private static function responseHandler (event:ResultEvent):void {

                  //var event:ResultEvent;

                  response = JSON.decode(event.result.toString());

                  //Alert.show("cid (da restmanager): "+response);

                  PhiLogger.log("REST Manager", "Operation: response ", "Requested");

                  responseHandlerExecuted=true;

        }

TOPICS
ActionScript
303
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation