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

i tried the following to no avail

-     this.home_m.gotoAndPlay("home");            [this one reported no errors, but stopped at the end of the first movieclip and did not move to the next movieclip in the root timeline]

-     home_m(this.root).gotoAndStop("home");     [this one moved along the root timeline to the end and then started over, did not completely load the fist movieclip or the second movieclip in the root timeline]

home_m = 2nd movieclip instance name / home = the frame label in the root timeline where movieclip home_m resides.

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

-     i placed the actionscript in the actionscript layer in the first movie, in the last frame.

-     i have a stop(); in the root timeline below each movie clip.  [usually i have the movieclips in the root timeline in 2 frames, so flash can enter the first frame, play the move and i have the stop(); in the second frame, in the actionscript layer]

Ned Murphy
Ned MurphyCorrect answer
Legend
October 22, 2009

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.