A script wait before firing

We are building an app with Hype and invoke an external system from the same action as we trigger thank you sequence further down the timeline.
Unfortunately they both fire at the same time, and since the external system opens a new browser window it obscures the animation .

Is there a command in hype like ‘play done’  ( I don’t remember whether this was from Director or Flash) that would make the external app wait until the thank you was complete before launching?

Option in Hype using Keyframe

You can call a JavaScript function with a key frame …

And then you can code in the Callback function


Option in pure JavaScript

Another way is purely in JS using the HypeTimelineComplete callback… and it doesn’t need any keyframes. This example test is the scene name and timeline name matches and lives in HeadHTML

<script>
function timelineComplete (hypeDocument, element, event) {
    	if(hypeDocument.currentSceneName()=='myScene' && event.timelineName == 'Main Timeline') {
    		//do your stuff
    	}
}


if("HYPE_eventListeners" in window === false) { window.HYPE_eventListeners = Array(); }
window.HYPE_eventListeners.push({"type":"HypeTimelineComplete", "callback": timelineComplete});
</script>
4 Likes

Thanks Max!

1 Like

Hi Max,

Thank you for your solution. It looks pretty straightforward. I am fairly new to Hype, and am struggling to use your pure JScript solution. I can get the callback to fire, but only once, on the page render. Is there a way to get the callback to fire each time the timeline is run?

For reference, I have actions on a few different elements that jump to a certain point in the timeline, and then continue the timeline from that point. When these actions are hit, I see the timeline executed as normal, but the JS callback is not called an additional time.

Thank you.

Do you think you could share your example files so we can dig into how you're structuring this?

I would be glad to send you the above widget we are developing with hype. Can you possibly sign a non disclosure? Thanks - Robit Hairman