Availablity of Variable Values between .swfs

I have a question about the availablity of variable values from one .swf to another that I think might be at the root of a lot of weirdness going on in my development environment.

Basically I have one .swf, which I call “index” which serves as the shell interface for my movie. It contains a navigation bar on the left and almost nothing else except for a large, empty movieclip “c”, which serves as the target into which seperate .swfs are loaded in order to display dynamic content.

The following code is used to load data from the server and to declare the function which is used to navigate.

one = new LoadVars();

one.onLoad = function() {
_global.template = _level0.one.template;
_global.page = _level0.one.page;
_global.button = _level0.one.button;

loadMovie(“http://dev.this_site.edu/generic_”+template+".swf", “_root.c”);


function loader(page, button, frame) {


Most often the “template” value serves a page called “generic_one” and loads it into the movieclip “c” on the root timeline. That template contains several dynamically populated elements. For simplicity’s sake, I will use just one of these to exemplify my difficulty.

There is a dynamic textbox named “teaser_mc”, which populates this way:

teaser_mc.teaser.htmlText = _level0.one.the_teaser;

Where “the_teaser” is one of several variables loaded into the LoadVars object “one” declared in the first line of code cited above, located on frame one of my shell of “index” movie.

Now here’s the thing.

When I test this from within the application by running “test movie” on the shell, I can press a navigation element and my template will load, but the textfields are empty. If I press that element again, it will populate the screen appropriately. When I publish it and look at it on the web, it seems to behave correctly, though I suspect that to be nothing but a benevolent quirk.

In an effort to figure out what was going on I tried running this “trace” statement:

trace (_level0.one.the_teaser);

first from within this function literal on the shell, which you can locate in context in the codeblock at the top of this post:


one.onLoad = function() {
_global.template = _level0.one.template;
_global.page = _level0.one.page;
_global.button = _level0.one.button;

like this —>trace (level0.one.the_teaser);
"+template+".swf", “_root.c”);


which returned the proper value every time.

Then I tried running the same statement from inside the code located on the first frame of the template .swf “generic_one”, which contains the dynamic text fields. Correspondent to the scenario mentioned above, where I had to press the navigation elements twice in order to populate my screen, my trace statement returned “undefined” when the .swf first loaded, and then returned the proper value when I pressed the element again and it populated the fields.

My question, obviously, is why is this happening? I have a feeling that many of the little quirks I have uncovered in building this site and the reason that certain necessary functions (like getting the BrowserHistory class to engage the browser’s back button – a subject I am certain to bring to show and tell later) are behaving erratically are related to this problem.

If I understand the code I cited early correctly, what I am asking Flash to do when the function “loader” executes is to send a query to a cold fusion page and load the returned data into the LoadVars object “one”. I am using the .onLoad method of that object to tell Flash to wait until it has all the necessary data before it loads the template .swf which refers to those values to populate itself with content.

Why, then, if that code is actually doing what I think it should, would those values not be visible from within my “generic_one” template when it first loads, seeing as I have asked Flash not to load any template until it has the data necessary to populate that template?

Does this seems like a data lag issue? Or does it have something to do with how seperate .swfs need to talk to one another when referring to variable values declared in one place and accessed in another?

Perhaps it is something entirely different. I am hoping in any case that I am bumping my head up against a know issue, since it seems that the scenario I am describing might be fairly typical.

Any advice or pointers would be extremely helpful.

I hope that was clear enough.

If you’ve read this far, I thank you.