CallResponder is used to track & capture the results of asynchronous calls made to RPC based services like HTTPService, WebService, RemoteObject etc..
Here is a quick working sample to demonstrate the use of CallResponder:
<?xml version="1.0" encoding="utf-8"?>
xmlns:mx="library://ns.adobe.com/flex/halo" width="400" height="400" backgroundColor="#7F7F7F" creationComplete="application1_creationCompleteHandler(event)">
protected function application1_creationCompleteHandler(event:FlexEvent):void
updateCONVERTER_AGENTSResult2.token = hs1.send();
<s:HTTPService id="hs1" url="http://srinivasannam.wordpress.com/feed/"/>
<s:CallResponder id="updateCONVERTER_AGENTSResult2" result="Alert.show('Successfuly updated');"/>
Awsome mate, your one helpful Adobe person
I'm use to doing things manually in FB3 like so:
<mx:RemoteObject id="myService" destination="ColdFusion" source="staff" showBusyCursor="true">
<mx:method name="getTargetData" result="handleGetTargetData(event)" fault="Alert.show(event.fault.message)"/>
<mx:method name="getTargetDataTable" result="handleGetTargetDataTable(event)" fault="Alert.show(event.fault.message)"/>
What advantages does this new way in using CallResponders have over my old method, apart from being auto generated?
I've also being looking at some of the generated classes:
* This is a generated class and is not intended for modfication. To customize behavior
* of this service wrapper you may modify the generated sub-class of this class - CONVERTER_AGENTSService.as.
internal class _Super_CONVERTER_AGENTSService extends RemoteObjectServiceWrapper
private var _cONVERTER_AGENTSRPCDataManager : RPCDataManager;
private var managersArray : Array = new Array();
the code is really over my head and I wonder what is the point of it all is. Is it for perfomrance gains when using many remote services?
Apart from wrapping the RemoteObject, HTTPService and WebService functionality, the generated code also has capabilities to
a. support paging of data
b. client side data management including options for batch commits
c. automatically deserialize XML / JSON response to AS objects in case of HTTP requests
d. If you are using LCDS, then automatic support for associations, lazy loading
The list is not exhaustive, but hope this helps
The old way seems to work well when there are less methods and you actually know them so that you can hand code.
With Data Centric Development in FlashBuilder 4, the following can be helpful
a. Introspection of the component, so that users need not hand code methods
b. The service wrapper (the _super* file) provide other functionalities as described in previous post of this thread
Using callresponders help in achieving a and b.
Would it help if we make the service call look more like a normal function call, and abstract out the call responder in the wrapper? We would like to see how developers want to see their service invocations looks like?
I feel honoured your asking me. I like seeing the complexity as I
think their is too much abstraction in the programming world.