# Simple Movieclips running before loaded

**URL:** <https://forum.kirupa.com/t/simple-movieclips-running-before-loaded/279272>\
**Category:** Uncategorized\
**Created:** [January 12, 2009, 4:00pm UTC](https://forum.kirupa.com/t/simple-movieclips-running-before-loaded/279272 "2009-01-12T16:00:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fhrosty](https://avatars.discourse-cdn.com/v4/letter/f/e480ec/32.png) [@Fhrosty](https://forum.kirupa.com/u/Fhrosty)\
**Post date:** [January 12, 2009, 4:00pm UTC](https://forum.kirupa.com/t/simple-movieclips-running-before-loaded/279272/1 "2009-01-12T16:00:33Z")

</div>

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
