I’ve encountered what seems to be a race condition between a parent and its child movie clips, but I don’t know what to do to fix it.
The parent movie clip is on the stage at compile-time, and the clip contains a number of children. In the parent’s constructor function I have the following code
for(var i in this){
if(this* instanceof MovieClip){
this*.hval = this*._x;
$tItems.push(this*);
this*.subscribe(this);
}
}
I’m able to give every child an hval property and push it into $tItems, but the call to the child’s subscribe method fails every time. It’s as though the child’s functions haven’t been loaded because the children haven’t yet realized that they’re members of a class that have a subscribe function. I set up a button to test this function call manually and when I do it that way I succeed in calling the subscribe method in all the children, so it really seems to be some sort of race condition.
How can I overcome this?