Copy link to clipboard
Copied
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 🙂
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).
Copy link to clipboard
Copied
myMC needs to be in the properties panel (ie, instance name, not symbol name) and it needs to exist when your code executes.
Copy link to clipboard
Copied
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 !
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
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 !
Copy link to clipboard
Copied
:
createjs.Ticker.addEventListener("tick", f.bind(this));
function f(e){
if(this.mc){
// do whatever
createjs.Ticker.removeAllEventListeners('tick');
}
}
Copy link to clipboard
Copied
Thank you very very much !!
Copy link to clipboard
Copied
you're welcome.