• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Animate Project - Keyboard functions

Explorer ,
Jun 15, 2022 Jun 15, 2022

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

Views

64

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 16, 2022 Jun 16, 2022

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines