2 Replies Latest reply on Jan 15, 2010 7:15 AM by dwelford

    Flash Builder 4 - Web Services

    dwelford Level 1

      Hi,

      I am using the Flash 4 beta to connect to web services, my connections are fine and everything works as it should.

      I added a call to the web services on a button Click event and noticed I need to somehow wait for the response back from the web services before continue with the click event. How do I wait for the result back from the web services call in a button click event?

       

       

       

      Thanks

      David................

        • 1. Re: Flash Builder 4 - Web Services
          Sameer Bhatt Adobe Employee

          Are you doing something like this -

          protected function button_clickHandler(event:MouseEvent):void

          {

                  webService.operation1();

           

                  .....some code here......

          }

           

          So, as the calls are aynchronous, you'll not get the response just after calling the operation.

          You need to wait for the result from the operation call and do things after the result has come, something like -

           

          private var operationResult:CallResponder = new CallResponder();

          protected function button_clickHandler(event:MouseEvent):void

          {

                  operationResult.addEventListener(ResultEvent.RESULT,resultHandler);

                  operationResult.token = webService.operation1();

          }

           

          protected function resultHandler(event:ResultEvent):void

          {

                  // result can be accessed through operationResult.lastResult or event.result

                  .....some code here......

          }

          • 2. Re: Flash Builder 4 - Web Services
            dwelford Level 1

            That worked perfect.

             

            Thanks

            david................