Hi friend!
I’m confused by your code. It’s all commented out. What’s with the slashes?
Anyway, I’m in a rare mood tonight, so I decided just to create a template…
input-colors.hypetemplate.zip (34.5 KB)
Basically, I used the following code…
color = hypeDocument.getElementById('field').value;
color = color.toLowerCase();
console.log(color);
hypeDocument.showSceneNamed("" + color + "", hypeDocument.kSceneTransitionCrossfade, 1.1);
When the “Go” button is pressed, it checks the value of the text field. If it matches the name of a scene, that corresponding scene is loaded. I used the “.toLowerCase” method so that it’s not so particular about the typing… there are scenes for “black”, “red”, “green” and “blue”.
WARNING – This is not a sanitized input… https://xkcd.com/327/ …Using fields without sanitizing the data could be very dangerous. This is just a quick example of how to change scenes based on input data.
If it’s a standalone page, where the input field is like a password code to load a game level locally in the Hype project, then maybe it’s not such a high risk. If this is being used to write to a database, the input value should be sanitized. Posting data to a server that is not cleaned could be very VERY bad!