2 Replies Latest reply on Feb 17, 2010 8:13 AM by msakrejda

    AMF methods

    hidarikani Level 2

      This remote PHP function call via AMF:


      trace(zendAmfService.getLastName('John'));

       

      outputs to the console:

       

      [object AsyncToken]

      But it should output a string (last name of John). What am I doing wrong?

        • 1. Re: AMF methods
          Sebastien V. Level 3

          You need to implement a IResponder and use it.

           

          var token:AsyncToken = zendAmfService.getLastName('John');
          token.addResponder( responder );
          

           

          Your String result will then come back in the IResponder result method, encapsualted in an event (in most cases in a ResultEvent).

           

          public class MyResponder implements IResponder {
               public function result( event:Object ):void {
                    var resultEvent:ResultEvent = ResultEvent( event );
                    var myResult:String = resultEvent.result; // Your AMF call String result
               }
          }
          
          1 person found this helpful
          • 2. Re: AMF methods
            msakrejda Level 4

            Alternately, you can listen for the ResultEvent and FaultEvent events from the service. AMF calls are asynchronous, so the results are not available when the method call returns. As the other poster pointed out, you get an AsyncToken that is related to that particular invocation of the remote operation. If you're calling a single method on the service, it's easiest to just add listeners for the service events. If you're doing something more complex, AsyncTokens are the way to go.