This content has been marked as final. Show 4 replies
AsyncToken is one way to go. Here's an example where an AsyncToken is used. Note that inline functions are being used for result and fault handing but you can break these to seperate functions as well.
var fillToken:AsyncToken = dsDataService.fill(arrayList);
function (result:Object, token:Object=null):void
// Do something with the result
function (error:Object, token:Object=null):void
// Do something with the error
Right, I'd much rather see people start out with normal AS3 functions to
simplify things until they get a handle (pun intended) on the nature of async
private function doFill():void
var token:AsyncToken = dsDataService.fill(arrayList);
var responder:AsyncResponder = new AsyncResponder(handleResult, handleFault);
private function handleResult(event:ResultEvent):void
trace("Result received. Length = " + arrayList.length);
// Handle result.
private function handleFault(event:FaultEvent):void
// Handle fault.
See http://livedocs.adobe.com/flex/201/langref/mx/rpc/AsyncResponder.html too.
I prefer inline functions for simple one/two liner result/fault handling and break them into seperate functions when the handling logic gets more complicated. People have different styles and I don't think there's one right/easier way.
Mete & Peter,
Thanks for the quick response; just what I was looking for.