I have been lookin for a solution for this for a while now. How do I access a movie clip thats on the stage from a nested movie clip? root doesnt work like it used to with AS2.0, is there a way? Any help would be highly appreciated
I used to run into this problem when I first switched from AS2 to AS3. I don’t anymore because I’ve learned to design my nesting structures differently. Most times, you can run whatever code you need to from the main timeline, without having to worry about backtracking your nesting structure.
I’ve had good results using a random combination of parent, this.parent, *this.parent.parent *that I still don’t understand. If all this does you no good, see if you can think outside of the box. (and by that I mean placing your code outside of your movieclip)
Thank you for the reply I know I have been ‘thinking outside the box’ :bucktooth: and so far I have managed to keep my code on the main TimeLine but it would make it sooooooo much easier to have access to it, see what I dont get, they say this language is meant to be Object oriented, but even if u create an object, how can you access the variables in the main TimeLine from within a MC. Im sure there is a way there has to be.
hope someone answers your questions mjg08.
this is the exact same problem that i’m experiencing!!
i was beating myself up thinking that i should structure the whole thing differently maybe , making classes for things etc… but i’m just not convinced it’s always easiest. not in my case anyway.
i can remove the nested clip using this.parent.parent.removeChild(this.parent) etc… but i want to be able to push onto an array that i hold in the master swf, and change a variable based on what button the user clicks in the loaded swf.
somebody help… please ??? there must be a way
Hey guys,
…I am also in the painful transition from as2 to as3 right now, and have run into this problem as well.
What works for me most of the time is casting the root as a MovieClip.
What used to be
_root.MyClip.MyVar
is now
MovieClip(root.MyClip).MyVar
Thank you 0L4F it worksssss now I have access to any variable on the stage thanks to everyone samuel123 just use MoviClip(root).myVar if you’re inside a MC and want to access myVar on the stage