In the piece of code below I would like to know the difference between doing this:
protected function servicesmainService_resultHandler(event:ResultEvent):void
services = getTopServicesmainResult.lastResult;
and this ...
services = event.result; (which won't compile)
Where services is an instance of ArrayCollection, the event comes from the result of a callResponder instance and the getTopServicesmainResult is the same callResponder id?
In debug the elements (ArrayCollection of valueObjects) all look the same, so which is better practice?
Also is it better practice to handle the result event from the callResponder as I'm doing here or from the rpc data service instance?
Thanks in advance,
CallResponder.lastResult - This is untyped. Hence there are no compiler errors in that statement. This is bindable. Which means that if you hook it to a datagrid,etc everytime a call is made the datagrid will change its values in accordance with the most recent result.
event.result - The default returned type is Object whereas the variable services in your example is of type ArrayCollection. Hence to make that succesfully compile the change required is
services = event.result as ArrayCollection;
About your query regarding handling of events. If you assign a result event for a callResponder, then the event handler is called only when the operation associated with the callResponder is invoked. On the other hand, if you assign a result event to the rpc data service instance, then the event handler is called when any operation within that service is invoked.
My practice is to handle result events USING Callresponders(as it varies between operations) and handle fault events using RPC data service instance.
Hope this helps and that I understood your questions correctly.