January 15, 2018
Captivate 2017 – JavaScript to delay next action
Comments
(4)
January 15, 2018
Captivate 2017 – JavaScript to delay next action
Newbie 1 posts
Followers: 0 people
(4)

Hello,

I was wondering if it is possible to use JavaScript to delay the next action, similarly the way you would using advanced actions. I don’t see this information listed anywhere in the JavaScript Interface.

Thanks

4 Comments
2018-01-16 12:48:51
2018-01-16 12:48:51

How about something like this?

This is an example I did to test for a single slide that changes the state of a box after 5 seconds.

setTimeout(changeBox, 5000)

function changeBox() {
cp.changeState(“box”,”afterTimer”);
}

The number 5000 is in milliseconds and can be adjusted for the delay.

Like
(2)
(3)
>
Greg Stager
's comment
2018-01-16 15:10:28
2018-01-16 15:10:28
>
Greg Stager
's comment

Thanks Greg, this worked!

Like
>
Greg Stager
's comment
2018-01-17 16:54:05
2018-01-17 16:54:05
>
Greg Stager
's comment

Just to build on this, if you use setInterval, it will continue to fire a function with timed ‘intervals’ in between. setInterval is good for countdowns and timers whereas setTimeout is good for delaying a function only once.

Like
>
Greg Stager
's comment
2019-06-18 20:06:46
2019-06-18 20:06:46
>
Greg Stager
's comment

That’s exactly what I was looking for, Greg. Fantastic.

Thanks

Like
Add Comment