Forum Discussion

EsmeraldaBar868's avatar
EsmeraldaBar868
Community Member
4 months ago

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 three slides. 

 

Thanks in advance! 

  • Hi,

    I would put those slides in their own scene and then on each slide include a text box with a reference to the built in built-in variable Scene.Elapsed.Time. The only hiccup there is that it counts upwards. 

  • JimCarry's avatar
    JimCarry
    Community 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);

    • EsmeraldaBar868's avatar
      EsmeraldaBar868
      Community Member

      Thank you, Jim! I used this code and it worked! I really appreciate it. 

  • Here's  a 60 second timer that runs  over three screens - it's based on a Start-Pause-Reset timer I had created ages ago - but with a bit of tweaking it seems to work OK. You would have to work out how to make the digital clock display do more that one minute - I have done that in other projects and can look it up if you need it....

    This doesn't use ANY Javascript - it's just keeps switching between layers (but, because of that the clock isn't Greenwich atomc clock standard as a result!)