Multiple Event.COMPLETE functions
There are occasions where you need to react to multiple Event.COMPLETE functions. This simple scenario had me scratching my head, so here's the simple answer:
Create a third function and call that at the end of each
Event.COMPLETE function, just after setting each flag to true.
code example:
//when finished loading some file
loader1.addEventListener(Event.COMPLETE, someFunction);
//when finished loading another file
loader2.addEventListener(Event.COMPLETE, someOtherFunction);
function someFunction(){
flag1 = true;
checkBoth();
//etc
}
function someOtherFunction(){
flag2 = true;
checkBoth();
//etc
}
function checkBoth(){
if (flag1 == true && flag2 == true)
{
trace("Both events are complete/loaded");
}
}
Copyright Gary Rosenzweig
