How do I Create code in JavaScript for a button that will show random scenes in my hype project?

Do I make an array with the scenes and use math.random function?

Yep. That’s about it :wink:

Hype’s API would make things nice and easy (providing you are using unique names in all your scenes)

var scenes = hypeDocument.sceneNames();
	
hypeDocument.showSceneNamed(scenes[getRandomScene(scenes.length)])
	
function getRandomScene(length) {
    return Math.floor(Math.random() * Math.floor(length));
}
3 Likes

Elegant :sunny:

2 Likes

Thank you DBear!