Simple Movieclips running before loaded

I’m sure this problem has to be discussed already somewhere, but all I can ever find is forum topics related to preloaders for external content which sounds a bit overboard for all I’m trying to accomplish. So please forgive me for posting if this topic has already been run into the ground, but…

When I dynamically add an instance of a movieclip to my stage, and shortly there-after attempt to call a function of that MC from the stage, the function attempts to run before the instance’s internal variables have been initialized. Here’s an example of what I mean:


(in MovieClip “Test”)

var abc = “xyz”;
trace(abc);
function tryIt():void {
trace(abc);
}

(on the main timeline)

var t = new Test();
t.tryIt();


this results in:
-undefined
-xyz

Since “tryIt” is not a function I necessarily want to run for every instance of Test I create (for example, if I’m loading items from a data source and some need to be displayed just a little differently), I’d like to call it specifically from the main timeline. Obviously I could just create two versions of my MC, one that runs the function automatically, and one that doesn’t have it at all, but that seems pretty inefficient. Any suggestions?

  • Fhrosty