Ollie
(Ollie)
May 9, 2020, 7:05pm
1
Hi there,
Looking to delay the javascript below from running straight away, I imagine a setTimeout function could be combined to achieve this, just not sure how it would be added.
Any help greatly appreciated,
Thanks.
if (window.currentTimeForScene1 != null) {
hypeDocument.goToTimeInTimelineNamed(window.currentTimeForScene1, 'Images');
hypeDocument.pauseTimelineNamed('Images', hypeDocument.kDirectionForward);
} else {
}
Rick4F
(Rick)
May 11, 2020, 5:42am
2
I did a forum search (always a good idea as it's filled to the brim with past problems & solutions), for "delay javascript" and ran into this:
Thanks for the request!
The current workaround/recommended method is to use javascript that would have a continue after a delay:
hypeDocument.pauseTimelineNamed('Main Timeline');
window.setTimeout((function () {
hypeDocument.continueTimelineNamed('Main Timeline', hypeDocument.kDirectionForward, false);
}), 2000); // time to resume in ms
I'm not a JS guy, at all but my idea would be to use ^that code to stall a timeline where at some point your code will run.
So something like this: pause_timeline.hype.zip (14.9 KB)
4 Likes
jonathan
(Jonathan Deutsch)
May 11, 2020, 7:29pm
3
The basic form for a delay is:
window.setTimeout(function () {
/* place code here */
}, 2000); // 2000 is 2 seconds in milliseconds
I’ll also point out that this doesn’t necessarily need to be accomplished in code if you don’t want; you could make a new timeline (or, if appropriate, use an existing one) that has a timeline action to run your event at a specified time.
2 Likes
Ollie
(Ollie)
May 12, 2020, 10:24am
4
Thanks for showing the layout of the code.
Will get this added into the project.
Thanks again.
1 Like
petester
(Peter Borokhov)
April 4, 2023, 6:23pm
5
Hi Jonathan, I have something similar I'm trying to achieve here can you please take a look.
I was looking for a script that would pause the timeline for 5 seconds and if there are no movements in the scene continue timeline, however if there was a movement/interaction pause the delay for indefinitely and restart the delay of 5 seconds when no longer on the scene
I tried this but it doesn't seem to work in the same way Intended.