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

How to make a keyboard navigating multiple choice list in Flash and control it through actionscript?

Community Beginner ,
Jun 24, 2013 Jun 24, 2013

i am making an rpg style game in actionscript 3.0 and i want to make a multiple choice list. I know how to make the list with buttons and how to control it. My question is, how do you make a list that can be navigated using the keyborad arrows? What i am after is being able to hit up, and down to highlight the buttons and enter to chose the button.

TOPICS
ActionScript
394
Translate
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

correct answers 1 Correct answer

LEGEND , Jun 24, 2013 Jun 24, 2013

You'll need to make the buttons as movieclips so that you can control which display state they are in (highlighted versus not).

Then you need to set up a listener for the keyboard keys so that you can have the selected button change and the execute if the Enter is pressed.  Here is a basic setup for a keyboard listener that shows how to detect the three keys you mentioned...

stage.addEventListener(KeyboardEvent.KEY_DOWN,keyIsDown);


function keyIsDown(e:KeyboardEvent):void  {

         if (e.keyCode

...
Translate
LEGEND ,
Jun 24, 2013 Jun 24, 2013
LATEST

You'll need to make the buttons as movieclips so that you can control which display state they are in (highlighted versus not).

Then you need to set up a listener for the keyboard keys so that you can have the selected button change and the execute if the Enter is pressed.  Here is a basic setup for a keyboard listener that shows how to detect the three keys you mentioned...

stage.addEventListener(KeyboardEvent.KEY_DOWN,keyIsDown);


function keyIsDown(e:KeyboardEvent):void  {

         if (e.keyCode == Keyboard.DOWN) {

                 trace("DOWN");

         } else if (e.keyCode == Keyboard.UP) {

                 trace("UP");

         } else if (e.keyCode == Keyboard.ENTER) {

                 trace("ENTER");

         }

}

Translate
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