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

Animate ActionScript 3.0 does not recognize key presses when testing, or published. Game.

New Here ,
Nov 02, 2021 Nov 02, 2021

Copy link to clipboard

Copied

I am going through a book tutorial on creating games in Flash/Animate, and the game is using keyboard key presses (arrow keys, spacebar) to control game elements. When I test the game, and also when I publish the game in .swf and windows exe format. The keys do nothing. This used to work years ago when I went through these examples previously, but now they aren't. I've looked through some troubleshooting sources, and I see a lot of references to something like "when testing the game, go to "Control/Disable Keyboard Shortcuts" because apparently, the testing environment is using keyboard shortcuts and has priority. However, in the current versions (2021, 2022) of Animate, I don't see anywhere where I can tell it to disable keyboard shortcuts for the test environment. Is there anyone that knows what to do about this now in the current software?

P.S., I'm not using Flash Builder, or any other ActionScript coding apps. It's all done in Animate.

Thanks.

TOPICS
ActionScript , Code , Error , How to , Other , Product issue

Views

129

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 ,
Nov 03, 2021 Nov 03, 2021

Copy link to clipboard

Copied

are you assigning the listeners to "stage"?

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
New Here ,
Nov 04, 2021 Nov 04, 2021

Copy link to clipboard

Copied

Yes, I am.

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
Community Expert ,
Nov 04, 2021 Nov 04, 2021

Copy link to clipboard

Copied

it works for me.

 

 create a new fla 

add something to the stage. 

add your keyboard listeners

test by clicking whatever is on stage and then press your keys

 

if that fails, show your code 

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
New Here ,
Nov 04, 2021 Nov 04, 2021

Copy link to clipboard

Copied

SOLVED: I did a test, and further discovered that the key presses, do in fact work, but you have to mouseclick on the item first to give it the focus. Then the keystrokes will work. Even though the coding mentions the specific instance name or the Symbol.

However, I don't want to have to click something first. It's a game, I need the subject to just move. But I noticed that clicking anywhere on the stage made the arrows work.

I saw a post somewhere that talked about focus, so I established focus on the symbol with a simple   "symbol.focus = symbol;"

That made the arrows work on the symbol without clicking anywhere, but it outlined my symbol with a yellow square. Weird.

So the final solution was just to put the focus on the stage with "stage.focus = stage;" and everything works as expected. SOLVED!

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
Community Expert ,
Nov 04, 2021 Nov 04, 2021

Copy link to clipboard

Copied

LATEST

good 

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