Lock the Root

[ LiB ] 

Let's say you have a movie called Main.fla, which loads several Flash movies (SWF files) into it while it runs using the loadMovie command. One of these files is Footer.swf, and in Footer.swf you have a lot of code that refers to _root. If you run Footer.swf on its own, the code will run fine because _root refers to the main Timeline of Footer.swf. However, once you've loaded Footer.swf into Main.swf, _root will point to the Main.swf Timeline.

There are many of you that have had to deal with this little quirk over and over. With Flash MX 2004, there is a new Boolean variable called _lockroot that corrects this issue. Place the following code in the Footer.fla main Timeline:

 this._lockroot = true; 

Now, referring to _root in Footer.swf will actually point to the main Timeline of Footer.swf, even when it has been loaded into another movie. I don't know about you, but this is one of my favorites!

[ LiB ] 


Macromedia Flash MX 2004 Killer Tips
Macromedia Flash MX 2004 Killer Tips
ISBN: 0735713839
EAN: 2147483647
Year: 2003
Pages: 300
Authors: Shane Elliott

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net