Ocean
07-14-2008, 06:56 AM
Can anyone explain to me a way to make a function 'wait' until receives a particular event before continuing?
I have a function which receives the path to an XML file, then it processes the XML data, performs a number of calculations, then adds the resulting data to an object.
eg.
private function analyse():void{
//1.
processXML("XML/datafile.xml");
//2.
//further analysis with results of processXML()...after processXML is complete
}
processXML() sets off a chain of functions that perform different analysis . So what I'd like to do is dispatch an event in the last function of that chain that triggers analyse() to continue to step 2. I'd prefer not to have step 2 in another function called by an event listener if at all possible. Is there any way to make a function 'wait' for an event like this?
Sorry, this is probably a simple question, but I'm having trouble getting my head around whether it's something I can achieve with events.
Thanks,
Ocean
I have a function which receives the path to an XML file, then it processes the XML data, performs a number of calculations, then adds the resulting data to an object.
eg.
private function analyse():void{
//1.
processXML("XML/datafile.xml");
//2.
//further analysis with results of processXML()...after processXML is complete
}
processXML() sets off a chain of functions that perform different analysis . So what I'd like to do is dispatch an event in the last function of that chain that triggers analyse() to continue to step 2. I'd prefer not to have step 2 in another function called by an event listener if at all possible. Is there any way to make a function 'wait' for an event like this?
Sorry, this is probably a simple question, but I'm having trouble getting my head around whether it's something I can achieve with events.
Thanks,
Ocean