canvashtml5-canvascreatejsadobe-animate

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.


Solution

  • 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!