Refresh/Reload scene in Javascript


(Andrew) #1

Might be a little question, but i cannot seem to find how I would reload the current scene, in javascript. I need to put all elements back to its started state and position?


#2

You can jump to the current scene by running a scene action:

Or in JavaScript:

hypeDocument.showSceneNamed('scene 2', hypeDocument.kSceneTransitionInstant);

(That would need to be run within Hype’s JavaScript editor).

Additional scene transitions and API options can be found here: http://tumult.com/hype/documentation/3.0/#api-functions


(Andrew) #3

I have tried this, but it does not reload the scene, only show the scene. I need to reload?


(Markus Bjerre) #4

If you want to reload the whole page you can simply put this code snippet inside a new function:

 var startOver = function () {
window.location.href = window.location.href;
}

You can call the javascript in many possible ways. Either you use it together with a timeout function that will be reset on button press/mouse movement or add a button which triggers the function.
If you want to reset the scene; the code that Daniel gave you should work. I don’t see why it wouldn’t.

If you have used objects created in a timeline and want the timeline to reset you can add this code into a newfunction:

hypeDocument.goToTimeInTimelineNamed(timeInSeconds, 'timelineName')

Remember to change the ‘timelineName’ to the specific timelines’ name you’ve created, also change the timeInSeconds to 0 if you want it to go back to the beginning.


(Gabhán Ó Dochartaigh) #5

I think I am struggling with the same problem: Problem with drag and drop
Was this ever resolved?