Skip to main content
October 22, 2009
Answered

navigate movieclip to movieclip

  • October 22, 2009
  • 1 reply
  • 1350 views

i need help to this seemingly simple, yet frustrating issue i am having with AS3.

issue

i have multiple movieclips on a timeline and i need the first one to load, play through all frames, than i need flash to move to the next movieclip in the timeline [load, play, than stop and wait for user input].

-     i am completely new to AS3, i have used AS2 for years.

-     i am moving all production in our studio to AS3 [so no AS2 comments or recommendations]

-     i have been able to do this in AS2, but i understand that AS3 does not use roots, levels, etc.

-     i have tried the gotoAndPlay(); [but i am not setting it up correctly to navigate to root timeline to find the frame name that the next movieclip resides in.  in otherwords i can not get flash to go back to the root timeline]

-     is it better in AS3 to find the movieclip or the frame it resides in?

please help

This topic has been closed for replies.
Correct answer Ned Murphy

Although I had a typo in my example (should have been an upper case C for Movieclip), the intent was to take it more literally... try using...

MovieClip(this.root).gotoAndPlay("home");

"MovieClip(....)" is basically used to tell the compiler that the class of the object it is being told to deal with is a MovieClip object.  This is one of the aspects of AS3 that I find a bit stupid... if you do not cast the type of the object, the compiler will likely kick out an error indicating the class of the object as not being explicitly stated as a MovieClip type.  They kinda made it play dumb, since it will usually indicate it knows full well what it's dealing with.

1 reply

Ned Murphy
Legend
October 22, 2009

Someone may jump on this as bad practice, but if you want a leg up onto something resembling your old horse (AS2), if you want to talk to the root timeline....

AS2:  _root.gotoAndStop(someframe);

AS3: Movieclip(this.root).gotoAndStop(someframe);  // similar usage supported for 'parent'

The other approach that might be considered best practice would be to assign custom event listeners/handlers to your movieclips such that when they fire their special events, the event listener assigned to them in the main timeline hears it and triggers the event handler to take the desired action.

October 22, 2009

thanks ned, i will give it a shot and see if it works.

and yes i do want to learn good habits, its just that AS3 is new to me and i am so busy i have not had the time to read an AS3 book all the way through yet.  i am sure AS3 is superior to AS2, but right now it is very frustrating.

Ned Murphy
Legend
October 22, 2009

Yep... it sure can be, but over time the pain eases