Hello everyone!
I have a class, ClassA which is a MovieClip. Inside of that I have about 20 other MovieClips that are associated with ClassB.
In my main timeline I have something like this, instantiating ClassA and then calling a setup function in it.
Code:
var obA:ClassA = ClassA(attachMovie("ClassA", "classA", getNextHighestDepth()));
obA.setup();
Then in ClassA I have this, the ClassB type variables are declared at the top because they are on the stage inside of ClassA.
Code:
public class ClassA extends MovieClip {
public var obB1:ClassB;
public var obB2:ClassB;
...
public var obB20:ClassB;
public function ClassA() {
}
public function setup():Void {
obB1.owner = 0;
obB2.owner = 1;
obB3.owner = 2;
...
obB20.owner = 19;
}
}
This is all very boiled down compared to what I have. But the problem is that the constructors of all the ClassB instances inside of ClassA are being called AFTER the setup() function is being called, and therefore I can't access any properties inside of those ClassB variables!!
The only solution I've come up with is to instantiate ClassA and then use a timeout to call the setup function in the class after a delay so that everything gets initialized before I try to access them!! And I don't like that solution at all!
Does anyone know of a better way to accomplish this??
Thanks!
Kyle