Copy link to clipboard
Copied
Hi everyone,
I wonder if someone could help me. I'm making a website using Adobe Animate with the goal of making it look like a video game. Most of what I want to do I've figured out, but I'm wondering if someone could help me with a finer detail that's escaped me. At the beginning of the website/game, a button will appear on the screen saying "Press X to continue". What I want visitors to be able to do is either of the following;
- Upon mouse click of the button, proceed to frame X and stop.
- Upon pressing X on the keyboard, proceed to frame X and stop.
Does anyone know how this is achievable please? Many thanks to all who respond!
Chris
Copy link to clipboard
Copied
Hi.
You could write something like this:
var root = this;
function startFromPointer()
{
root.gotoAndStop(1);
}
function startFromKeyboard(e)
{
if (e.key === "x")
{
window.removeEventListener("keydown", startFromKeyboard);
root.gotoAndStop(1);
}
}
root.stop();
root.pressToStartButton.on("click", startFromPointer, null, true);
window.addEventListener("keydown", startFromKeyboard);
I hope it helps.
Regards,
JC