all groups > flash actionscript > april 2004 >
You're in the

flash actionscript

group:

about _root, _level50 and local variables


about _root, _level50 and local variables zzdobrusky
4/27/2004 8:42:26 PM
flash actionscript:
Hi,
I guess this is about naming movies and calling local variables,
I have main tryOuts.swf and movie clip tryOuts_mcSquare.swf that is loaded to
level 50 above main, I have also local variables yMain in main and ySquare in
mcSquare, I already tried absolut paths to call _root.tryOuts_mcSquare.ySquare
or _root.yMain but all variables are traced as "undefined", what interesting
is that when I declare _global.tryOutsMainTimeline = this; and call variable
tryOutsMainTimeline.yMain from tryOuts_mcSquare it works perfectly, but when I
call tryOutsMainTimeline.tryOuts_mcSquare.ySquare from main it just won't work,
I also tried something like
tryOutsMainTimeline._level50.tryOuts_mcSquare.ySquare , all is happening on the
1st frame of main and loaded movie,
thanks for any help
Zbynek
Re: about _root, _level50 and local variables Peter Weidauer
4/28/2004 2:47:20 AM
Zbynek, I never use levels, but I think this should work:

// frame 1 of tryOuts.swf
var yMain = "level 0";
this.loadMovie("tryOuts_mcSquare.swf", "_level50");

// frame 1 of tryOuts_mcSquare.swf
var ySquare = "level 50";
// I believe you cannot use _root here since it refers
// to the main timeline of THIS level
trace( "_level50 sees: " + _level0.yMain );


Now, to access tryOuts_mcSquare.swf's variables you have to wait until
the movie is loaded. Then you should be able to read them from _level0
like this:

// main timeline of tryOuts.swf after _level50 is loaded
trace( "_level0 sees: " + _level50.ySquare );


HTH,
Peter
Re: about _root, _level50 and local variables zzdobrusky
4/28/2004 4:28:01 PM
Hi Peter,
thanks for advice, it worked perfectly when I used
loadMovie("tryOuts_mcSquare.swf", "_level50");
also worked when
loadMovie("tryOuts_mcSquare.swf", 50);
this.loadMovie didn't work,
I was wondering when I actually use _root and _parent, also that "this"
anywhere confuses me, it reminds me something from C++ language,
with regards,
Zbynek
AddThis Social Bookmark Button