Link to home
Start Free TrialLog in
Avatar of sousflai
sousflai

asked on

how to target the original root from a loaded movie

I've got a large project which I've had to disect into chunks.
I'm loading each swf in as a loaded movie with loadMovie("addprovider.swf", 1);
inside the addprovider.swf is a movie clip. At the end of this movie clips timeline I would like it to target the root of the holding original swf and get it to move on a frame to simultaneously unload the movie and load in the newt in the sequence.

ive tried
this._lockroot = true; on the first frame of the main swf with _root.gotoAndPlay(2); in the loaded movie but it isnt working,

the second frame of the main swf unloads the movie with
stop();
unloadMovie(1);
loadMovie("addclient.swf", 2);

I would be very grateful for any help!
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

if you use "this.lockroot=true" in any swf or in any movieClip, it means, that SWF or movieClip and all its child movieClips are refering it as "_root". "_root" has been locked for them, they can't go beyond that level.

1.
if you have not used "_lockroot=true" in child swfs, then you can simply access parent _root using "_root"

2.
but if you have used "_lockroot=true" in child swfs, then you can't acess parent "_root" directly..

wordaround in this scenario is, after child SWF loading you have to set a parent "_root" pointer inside child SWF.. for example:
------------
loadMovie("addclient.swf", 2);

//check for loading completion
this.onEnterFrame = function()
{
   if(_level2.getBytesTotal()==_level2.getBytesLoaded() && _level2._width>0){
     _level2.mainroot = this;
     delete this.onEnterFrame;
   }
}

----------------

now you can access parent "_root" inside child SWF using "_root.mainroot"

-Aneesh
ASKER CERTIFIED SOLUTION
Avatar of blockage1
blockage1

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
blockage1 is correct.

If you use _level0, you'll target the topmost level :)