I’m trying to have a button press save a scene name to a variable and then go to that scene later.
I establish a global variable in the HTML:
window.linkTarget = "";
So then in the timeline, I pause for a user selection. When they click, the buttons call individual functions to set the variable with a scene name and playback resumes.
window.linkTarget = "Call to Action"; // Scene name
At the end of the animation it runs and the button invokes a function to go to the selected scene name:
hypeDocument.showSceneNamed(linkTarget, hypeDocument.kSceneTransitionCrossfade, 1.1);
However, this isn’t working. I know it’s not the most efficient way to do it, but I can’t even get this method to work. What am I doing wrong?
Hi Nathan!
Using a variable for a scene name should not be a problem:
SceneVariable_JHSv1.hype.zip (37.7 KB)
Demo (one way to do it) - basically following your description above:
The document opens and “Main Timeline” runs and then pauses; user presented with a choice of buttons (which have IDs matching the Scene Names), which when clicked run this script:
function selectSceneClick:
window.selectedScene = element.id;
hypeDocument.continueTimelineNamed('Main Timeline', hypeDocument.kDirectionForward, false);
So the timeline continues to its end at which point this script is triggered:
function goToSelectedScene:
hypeDocument.showSceneNamed(selectedScene, hypeDocument.kSceneTransitionCrossfade, 1.1);
2 Likes
Thanks, that demo worked great. However, sometimes I have multiple buttons in different parts of a scene or in other scenes that link to the same thing. Having duplicate IDs seems to cause trouble sometimes. Would it be a good idea to try doing it using the class instead?