Thanks for sending that over.
It looks like you want to play a timeline, and when that timeline is complete, jump to a specific scene.
Typically, code is not required to do this. You could make a secondary timeline that plays the animation, and then that has a timeline action at the end of the timeline to jump to the scene.
If you do need code for more elaborate versions of your document, then I think the previous answer/explanation still basically holds. Because continueTimelineNamed
does not pause the execution of javascript, you will need to add your own time deferred call to showSceneNamed
so it changes scenes at the right time when the animation is complete. For this, you can use the window.setTimeout call, like so:
var delay = 1.0; // time in seconds
window.setTimeout(function() {
var escena = hypeDocument.sceneNames();
hypeDocument.showSceneNamed(escena[1], hypeDocument.kSceneTransitionCrossfade, 1.1);
}, (delay * 1000));
However, hard coding may mean that if you change the animation, this code will be stale and use the wrong time. You could instead use the Hype API to get the symbol timeline's duration and current time to figure out the appropriate point for the transition. (of course, this only works for simple timelines that don't have any pauses or playhead position changes)
The delay line would look something like:
var delay = symbolInstance.durationForTimelineNamed('timelineName') - symbolInstance.currentTimeInTimelineNamed('timelineName');
Further, right now we're using the scene names list to get the scene, but the index is being hard coded. If you were to change the scene ordering then you'd need to go back in code. Usually the scene name itself is a little more stable, so you can pass that in as the first argument as a string instead:
hypeDocument.showSceneNamed("2", hypeDocument.kSceneTransitionCrossfade, 1.1);
(it is "2"
because you literally named your second scene "2")
I hope that helps clarify it. I don't know where you're going with the project but my recommendation here would actually to be to avoid any of this code if you can still and just use timelines and timeline actions to achieve the desired effect.