Each call to a service function returns a PendingCall object. The Flash application does not wait for the result of the service function call. The application receives the result asynchronously. You can handle the result by setting the responder property of the PendingCall class to an object that implements the mx.rpc.Responder interface. The Flash Remoting API provides the mx.rpc.RelayResponder. When using the RelayResponder object, you must specify both the object and the methods that will process the result and fault outcomes of the service function call on that object.
You can import the PendingCall class using the following import statement:
import mx.remoting.PendingCall;
custService, for the customerData service and calls its getCategories() function. The service returns a PendingCall object, pc. The example sets the pc.responder property to a RelayResponder object that specifies the object (this) and methods, (onCategoryData() and onCategoryFault(), to receive the result and fault conditions that the getCategories() method could return. To see the full application, see Using the Flash Remoting ActionScript API in the CustomerInfoExampleAPI application.
// import Flash Remoting classes
import mx.remoting.Service;
import mx.services.Log;
import mx.rpc.RelayResponder;
import mx.rpc.FaultEvent;
import mx.rpc.ResultEvent;
import mx.remoting.PendingCall;
import mx.remoting.RecordSet;
// create custService service object to access customerData service
custService = new Service(
"http://localhost:8300/flashservices/gateway",
null,
"customerData",
null,
null);
// call getCategories() method to obtain list of categories and receive
// PendingCall object in return
var pc:PendingCall = custService.getCategories(); // get all categories
// Set PendingCall responder property to RelayResponder object that specifies
// the object and methods that will receive the result or fault condition that
// the service returns
pc.responder = new RelayResponder(this, "onCategoryData",
"onCategoryFault" );
See Also
mx.rpc.RelayResponder
mx.remoting.Service
| Properties | |
| responder:
Responder [
Read-Write]
Provides access to the associated responder |
| Property Detail |
responder:
Responder [
Read-Write]
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flashremoting/mx2004/actionscript_api_reference/mx/remoting/PendingCall.html
Comments
Corstiaan said on Apr 18, 2005 at 3:10 AM :