Below is a technique to create a ‘Back’ button within your Tumult Hype document which will take your users to the last visited scene. This does not override the Browser back button.
First, on all scenes where you want to remember visits, add this JS function to run ‘On Scene Unload’:
Hello Daniel, I really wanna use this trick.
Can you explain me how to use JS functions? I mean, how to run On Scene Unload ?
How Do I create a JS from zero?
If you open the attached .hype file above, you’ll see that in the Scene Inspector, there’s a ‘On Scene Unload’ action. More info can be found here under the ‘Actions’ chapter: http://tumult.com/hype/documentation/
There’s also more info on JavaScript functions and how to create them in the JavaScript chapter.
This is extremely helpful. Thanks to all who contributed. Another question: Any way to fine-tune the transition on the back button to crossfade for 0.5 second duration?
Thanks!
Is there any way to get this to go back more than one step? I run into a loop if it goes forward two steps.
For example:
Scene 1 > Scene 2 > Scene 3
If I go to Scene 2 from Scene 1, no problem to back out from that.
But if I have a back button that goes from Scene 3 to Scene 2, I can’t go from Scene 1 to 2 to 3 and eventually back down to Scene 1 from 3 because it always wants to go back from Scene 2 to Scene 3 in a loop after you hit 3.
Not sure if I explained that well. How the progression winds up looping, shown in a breadcrumb format below would be:
Scene 1 > Scene 2 > Scene 3 > Scene 2 > Scene 3 > Scene 2 > Scene 3, etc.
So if there is any way to get this to remember 2 steps, it would be great to see that listed here.
As it happens, the back buttons point to one of two scenes to start with, depending on which one of the two they started at. The subsequent 3rd scene can also be drawn from another starting point. So I actually do need some kind of capability in this regard.
I am afraid the description of what I am looking for is the best I can do. I am under a time crunch, and was hoping someone would be able to understand the description well enough to help.
I didn’t realize the problem I am having was going to be one until just prior to putting in my initial request here.
I started to put together a sample file, but quit when I realized the time spent completing it would cost me too much on the actual project.
Crossing my fingers someone can understand what I need - just to be able to go back 2 individual steps using a back button, to take you back the exact way you arrived from an original 2 step (or scene) path.
Yes - in addition to buttons there is a kind of menu system. There is a set of content pages that can be navigated to from two different locations. From each content page you can access a sort of case study and a few video pages.
If I were only going to the content pages everything would be fine, but accessing the case study and video pages from the content pages is what is causing the problem I am having.
Otherwise, I would create your own Javascript array which contains your history then add hypeDocument.currentSceneName() to that array On each Scene Load. Here’s a good cheatsheet for working with arrays.