0

I'm using Animate CC 2017 to create HTML banner animations.

After certain time, I like to stop animation. This code below stops the main timeline:

setTimeout(function(){
    stage.getChildAt(0).gotoAndStop(90);
}, 1000);

But if there are other movieclip animations in the main timeline, they continue to play.

I tried this to stop them:

    setTimeout(function(){
    stage.getChildAt(0).gotoAndStop(90);
    for (var i=0; i<stage.getChildAt(0).numChildren; i++){
        stage.getChildAt(0).getChildAt(i).stop(); 
    };
}, 1000);

but that didn't work.

Also I've tried selecting a certain movieclip by it's name. No luck there either.

Have anyone have a solution for this headache? Thanks.

1 Answers1

0

OK, I've solved this!

Problem was, not every object in the timeline has animation, therefore they don't have "gotoAndStop" as a function. So I needed to check if every object in the loop have that function. Below code works perfect!

    setTimeout(function(){
    stage.getChildAt(0).gotoAndStop(90);
    for (var i = 0; i < stage.getChildAt(0).numChildren; i++){
        if(typeof stage.getChildAt(0).getChildAt(i).gotoAndStop === 'function'){
            stage.getChildAt(0).getChildAt(i).gotoAndStop(10);
            }
        };
    }, 1000);