Skip to main content
Participant
November 9, 2016
Answered

How to use gotoAndPlay in Animate CC (Canvas) ?

  • November 9, 2016
  • 1 reply
  • 7798 views

Hi everyone,


I guessed it could be very simple (indeed, in Flash and ActionScript, it is !), but
may be I missed something (or something I don't understand) :

In my Animate CC document ( HTML5 Canvas ), I have a MovieClip called "myMC" on the stage.

Inside this movieClip, there is let's say 5 differents frames.

And there is also  this.stop() on the first frame of this movieClip...

Could anyone tell me why I can 't target my movieClip ?

I believed something as simple as this.myMC.gotoAndStop(4) could work...
but unfortunately, myMC stays at its first frame. Nothings seems to happen.

How comes ? How can I properly target a movieClip on my stage ?

Thanks a lot for your answers, and sure, your explanations 🙂

This topic has been closed for replies.
Correct answer kglad

one way to ensure the movieclip exists when executing the code is to put the code on the movieclip's timeline.

another is to use a loop (eg, ticker) to repeatedly check if the movieclip exists, and if it does, then execute your code (and terminate the loop).

and the most common way is to manually inspect the frame that contains that code and to manually check the stage at that frame to confirm the movieclip exists (and is named correctly in the properties panel).

1 reply

kglad
Community Expert
Community Expert
November 9, 2016

myMC needs to be in the properties panel (ie, instance name, not symbol name) and it needs to exist when your code executes.

Participant
November 9, 2016

Thank you very much for your answer, Kglad ! I really appreciate...

Well, myMC is also the name in the properties panel.
Thanks to your answer, I decided to put this.myMC.gotoAndStop(4) on the second frame of the main timeline,
to be sure it exists when the code executes...because the movieclip already exists in the first frame.
And it works !! Thank you very much.

But  I bet there is a better way to use it...

Could you give me an example to make it work ? What other ways can I have, to make sure myMC exists
when the code is executing ?

One more time, thanks a lot !

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
November 9, 2016

one way to ensure the movieclip exists when executing the code is to put the code on the movieclip's timeline.

another is to use a loop (eg, ticker) to repeatedly check if the movieclip exists, and if it does, then execute your code (and terminate the loop).

and the most common way is to manually inspect the frame that contains that code and to manually check the stage at that frame to confirm the movieclip exists (and is named correctly in the properties panel).