Forum Discussion
Need Some Help to Create Stop watch in storyline 360 with JavaScript
Hi guys,
can you help me to create stopwatch.
here is the code written but am not getting it properly.
can any one respond where went wrong in the code.
Thanks in advance
- ElearningDev699Community Member
- WaltHamiltonSuper Hero
Your link has problems. Can you re-attach it?
- ElearningDev699Community Member
- MathNotermans-9Community Member
Although this is far from complete, here are some fixes to help you get started.
- You need to check your variables. The NaN is caused by setting hours instead of Hours.
Do use consequent variable naming all the time. I use camelCasing... So instead of Hours i would name it stopwatchHours or swHours to be sure i get the proper var.
- Now the script is onlt executed at Storyline start. You need it to loop. I added a SlideLayer that loops in it. Quickly fixed it... can be improved.- ElearningDev699Community Member
Thanks for this response. But can you suggest me how to do only using JavaScript by not taking any layer loop.
like layer starts the stopwatch should be start irrespective of the time line loop. - ElearningDev699Community Member
can you check this once it's working till 59sec.
- MathNotermans-9Community Member
Ofcourse you can make a loop in Javascript only, but thats more complex. Mainly due to scope issues Storyline will cause.
https://www.programiz.com/javascript/for-loop
Here you find a lot of ways to create a loop in Javascript...easy enough... but as said Storyline scope issues make it more difficult, so you are better off using a SlideLayer loop.