Hi, I’ve got a nested movieclip here, and I would like to call another nested movieclip in the main timeline.
My main idea was to do:
MovieClip(root.instance).instance.gotoAndPlay(1); ,
but that doesn’t work (obviously, I’m a newbie).
Would I have to use parents or even children?
I’m using Actionscript 3.0 for this by the way.
Using the root approach, I think what you want is:
MovieClip(root).instance.gotoAndPlay(1);
The purpose of MovieClip(…) is to cast a variable to be a certain type - a type other than what’s defined for that class. The .root property, for example, is defined as a DisplayObject, but MovieClips, as DisplayObjects, can be what root points to, so you can tell the root property (not root.instance) that you want to treat it as a MovieClip which then allows you to reference .instance or whatever from it.
Thanks for the explanation. I kinda get it now.
I’m kicking myself right now for not thinking of that, though.
I mean, it’s like the easiest thing in Flash programming, am I right? xD
Thanks again.
Not really Especially if you have any background in AS2, this whole need-to-cast-root-to-use sometimes thing will throw you for a loop. AS2 didn’t have that problem, and people moving from there to AS3 get a little time-to-deal-with-typing slap to the face. Its not always clear why its needed, or even why root is typed that way to begin with. I may have a slightly better explanation in the tips entry about this: kirupaForum