Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to use gotoAndPlay in Animate CC (Canvas) ?

New Here ,
Nov 09, 2016 Nov 09, 2016

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 🙂

TOPICS
Code , How to
7.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 09, 2016 Nov 09, 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).

Translate
Community Expert ,
Nov 09, 2016 Nov 09, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 09, 2016 Nov 09, 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 !

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 09, 2016 Nov 09, 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).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 10, 2016 Nov 10, 2016

One more time, a big Thank you to you, Kglad !
Do you have a link with a tutorial showing the code / how to do for these solutions you propose ?

(especially to see if the movieclip exists)

Thank you very very much ! 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 10, 2016 Nov 10, 2016

:

createjs.Ticker.addEventListener("tick", f.bind(this));

function f(e){

if(this.mc){

// do whatever

createjs.Ticker.removeAllEventListeners('tick');

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 10, 2016 Nov 10, 2016

Thank you very very much !!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 10, 2016 Nov 10, 2016
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines