Halfacre
Halfacre

Reputation: 585

HTML5 Canvas/CreateJS stop all nested movie clips?

Working with Adobe Animate/Canvas, I have one large movie clip containing dozens of small clips nested inside. I'd like to make sure all these clips are stopped at runtime, but I don't want to go through each one manually. Is there a way to stop all these clips programmatically from the main timeline?

I tried this:

this.myBigContainingClip.stopAllMovieClips();

But that doesn't do it.

Upvotes: 0

Views: 455

Answers (2)

Kamel nazar
Kamel nazar

Reputation: 1

root=this;
const allmovieclips = root.children;
allmovieclips.forEach(element => console.log(element));

Upvotes: 0

Lanny
Lanny

Reputation: 11294

There is definitely no stopAllMovieClips method :) You can check out the docs here: https://createjs.com/docs/easeljs/classes/MovieClip.html

Similar to your other question, you will have to make sure the timeline is accessible. Note that this issue is recursive:

this.gotoAndPlay(0); // Update `this` timeline
this.myBigContainingClip.gotoAndPlay(0); // Update myMovieClip so you can access its timeline

Then you can iterate all the clips in the myBigContainingClip timeline, and tell them to stop

for (var i=0, l=this.myBigContainingClip.numChildren; i<l; i++) {
    this.myBigContainingClip.getChildAt(i).stop();
}

Note that this is pseudocode (untested), but it should work.

Happy coding!

Upvotes: 1

Related Questions