I wanna get two level results of an hierarchical structure. First results of AsyncToken is Ok,then I set a for loop and calling next level results by the same way in each loop step. Here is the problem, token2.addResponder(responder2); never return results on time,on each loop step. It sends me results after all for loop results. But I need in each step .
Can you please tell me about my wrong ?
public function getChildResultHandler(event:ResultEvent, token:Object=null ):void
{
myObject=event.result; //first asynToken result is Ok
var myArrayCol:ArrayCollection=new ArrayCollection();
myArrayCol=ArrayCollection(myObject);
var mlObject:MLObject=new MLObject();
var i:int;
for(i=0;i<myArrayCol.length;i++)
{
mlObject=myArrayCol[i];
if (mlObject.Type=="Bin")
{
token2=new AsyncToken(null);
token2=myService.GetChildObjects(sessionID,mlObject.ObjectID);
responder2=new AsyncResponder(getNextLevelChild,getChildFaultHandler);
token2.addResponder(responder2);
// I cant get results here
// this query goes to getNextLevelChild func after for loop results
}
}
}
Do I have to wait for both results, if yes, how can I wait the responder or token ?
Because, these are async calls. It's not possible to know order of returned results. May be first call will end first, may be second one.