Copy link to clipboard
Copied
var mySeconds = 5;
this.seconds_txt.text = mySeconds;
var timerId = setInterval(countDown.bind(this), 1000);
function countDown(){
if(mySeconds == 0){
this.myStopIntervalFunction(); //call to function fires but doesn't clear interval
clearInterval(countDown); //doesn't work
}
else{
mySeconds--;
this.seconds_txt.text = mySeconds;
}
}
this.myStopIntervalFunction = function (root) {
console.log("myStopFunction fired");
root.clearInterval(countDown);
};
I have no idea why its not working.
Copy link to clipboard
Copied
Hi.
You have to pass the interval ID not the function. Like this:
clearInterval(timerId);
More info:
https://www.w3schools.com/jsref/met_win_setinterval.asp
Regards,
JC
Find more inspiration, events, and resources on the new Adobe Community
Explore Now