Hi All,
I'm calling a function and adding a listener for when the function returns some data. when the data is returned i need to call another function and so on.
Is there an easy way to 'chain' these functions together so that the first one fires - waits for the listener then fires the second one creating a listener for that and so on until the last one calls a separate function that is defined at the start. It would i suppose work on the same lines as the bulk loader scripts.
I'm envisaging the code working something like this:
var dataLoader:DataLoader = new DataLoader(onAllComplete, onError);
dataLoader.add(getData1, {args1, args2}, listnerType.DATA_LOADED);
dataLoader.add(getData2, {args3, args4}, listnerType.DATA_LOADED);
dataLoader.add(getData3, {args5, args6}, listnerType.DATA_LOADED);
dataLoader.start();
private function onAllComplete(e:Array):void {
//where e contains an array of all the event results
}
private function onError(e:Event):void {
//will fire if there are any errors along the way
}
Thanks, Josh