Hello,
in the game catchingBirds there is the javascript “function timelineEventHandler(doc, e)”. For a project I’m looking for a way to stop this timer with a mouse click and then end it. I would be very grateful for useful tips, since I’ve been spending some time with it, unfortunately without any results.
greeting
Oscar
Hi Oskar,
You can store the timer id returned by setInterval
in the doc
global object, and pass it to clearInterval
function in your mouse click event.
// start the timer in a function / event handler
doc.myTimerId = setInterval(yourFunction, yourInterval);
// stop the timer in another function / event handler
if (doc.myTimerId) {
clearInterval(doc.myTimerId);
delete doc.myTimerId;
}
Regards
Hi,
Great, that was the impetus I was looking for. Sometimes you can no longer see the forest in front of many trees. Thanks.
greeting
Oscar
1 Like