Linking docs using a variable: Store the last visited scene


(mark) #1

Hi

I have a set of project files which the user can navigate around - all fine and dandy ( god, I love this software )

what I would like to do now is hold a variable that contains exactly where the user jumped from - that way i can navigate back to the exact point from which they left.

Is there a demo file that shows how to do this - my coding skills are useless so really need a demo.

Thanks


(Mark Hunte) #3

You can use a global variable.

In this example I have a function which sets the global var to the last scene name

window.lastScene = hypeDocument.currentSceneName();

The function is then set to run on each scenes “On Scene Unload”

I then have a buttons on each scene leading the a scene and a back button.

The back button runs a function to go to the scene with the name that the global var’s value matches.

LastScene.hype.zip (60.6 KB)

This should give you an idea of how to reach you goal using the global variable.


(Greg) #4

Cool Mark, I was doing something similar but couldn’t quite get it. Setting the variable was my block.

var lastSc = window.lastScene 

your method solved it YAY!


(Mark Hunte) #5

I only found out about the global vars a couple of weeks ago. I love the buggers. :smile: