Forum Discussion
EsmeraldaBar868
6 months agoCommunity Member
I need a timer that starts and continues through three slides
How can I insert a 15minute timer that counts down while users are in three specific slides? They need to be able to see how much time they have left while they move back and forth through these thr...
JimCarry
6 months agoCommunity Member
Feel free to try out the JavaScript code below. Additionally, create a new text variable named 'time' in Storyline, with a default value set to 15 minutes. Execute this script when the timeline starts. I hope you find this helpful!
var player = GetPlayer();
var sec = 900;
function startTimer(){
sec -= 1;
var minutes = Math.floor(sec / 60);
var seconds = sec % 60;
var timeString = minutes.toString().padStart(2, '0') + ":" + seconds.toString().padStart(2, '0');
player.SetVar("time", timeString);
if (sec < 0) {
clearInterval(timerId);
player.SetVar("time", "Time's Up");
}
}
var timerId = setInterval(startTimer, 1000);
- EsmeraldaBar8685 months agoCommunity Member
Thank you, Jim! I used this code and it worked! I really appreciate it.