all groups > flash actionscript > december 2005 >
You're in the

flash actionscript

group:

Help with carrying variable from MC to MC


Help with carrying variable from MC to MC Bucoholic
12/19/2005 10:42:21 PM
flash actionscript:
I have a file that I want to carry a variable from a MC that has buttons to a
separate MC that will load an image based on the variable. Here is what I have
so far.:

In the MC that loads the image I have:
loadMovie(pool+".jpg", "image");

Here is what I have on the buttons:
on (release) {
_root.gotoAndPlay(4);
pool = "images/test/SeaCovePool";
}

The Image MC is playing but it's not loading the image. I can place the same
code (with exception to _root.) into the same MC and it works fine. I need to
have the 2 MC in separate area's. Any help would be great.
Re: Help with carrying variable from MC to MC IwannaFlashU
1/4/2006 2:40:35 PM
variables, just like other objects have paths. Your POOL variable in one mc is
a DIFFERENT variable with the same name in another mc. Declare pool as a
_global variable or declare it in your _root timeline and then whenever you
access that variable, refer to it as _global.pool or _root.pool (depending on
which way you go with the declaration).

of course you could also refer to your current variables by putting the
absolute or relative path information in front of pool. for example, if you
have a main movie (_root) with two movies loaded inside of it, a_mc and b_mc,
if b_mc is trying to read POOL from a_mc, the code would either _root.a_mc.pool
OR _parent.a_mc.pool.

The reason why your code works when it's all inside of the same movie is that
POOL's path is the same throughout which means it is the only one being
accessed. Hope this helps.
AddThis Social Bookmark Button