Hype, javascript - continue timeline when movie ist finished

I am new to Javascript and have a question. In Hype I have a scene with a button. When I press the button a new window fades in with a movie (vtm_hs1) in it. This is achieved by activating a timeline (the timeline is called "Group_info1"). The movie should only be played once. After that the window should fade out by continuing to play the timeline (Group_info1) (or play the timeline backwards).

So far the movie starts correctly and stops even after playing once. But the window does not close. What am I doing wrong? Here is the code:

function play_vtm_hs1(hypeDocument, element, event) {


function myHandler(s) {


Thanks for your help

I suspect the problem is with this line:


If I make a sample project with it and look at the developer console, it logs this error:

Error in undefined: TypeError: hypeDocument.getElementById('vtm_hs1').loop is not a function. (In 'hypeDocument.getElementById('vtm_hs1').loop(1)', 'hypeDocument.getElementById('vtm_hs1').loop' is false)

This error would halt further execution, so your ended handler will never get added.

The line appears to want to set looping on the video; the correct code for this would be:

hypeDocument.getElementById('vtm_hs1').loop = true;

However, given what you've said you want to accomplish, it does not sound like you want this video to loop at all (if it loops it will never end!), so I would just remove the line entirely.

When I do so, your code, in my sample project, works. If it still has issues for you, feel free to attach a zip of your .hype project.

Hi Jonathan,
thanks for your help. I deleted the line but ist doesn't work. But then i found the mistake i made. That was really stupid of me. I accidentally put the name of the object in the script instead of the name of the timeline. Now it works.


1 Like

Great - I'm glad you were able to get it. I suspect the mistake was both :slight_smile:.