0

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.

Halfacre
  • 565
  • 8
  • 26

2 Answers2

1

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!

Lanny
  • 11,244
  • 1
  • 22
  • 30
  • Haha, thanks Lanny – in my defense, there is (was?) a `stopAllMovieClips` in AS3! Or so I heard. And, indeed, I'd actually gotten halfway there thanks to your answer to that other question. After that, completely lost. This works! Thanks once again! – Halfacre Jun 07 '19 at 21:58
  • Ha, it's been so long, I had forgotten! :) – Lanny Jun 08 '19 at 13:26
0
root=this;
const allmovieclips = root.children;
allmovieclips.forEach(element => console.log(element));
Kamel nazar
  • 1
  • 1
  • 1