Skip to main content
Known Participant
January 10, 2013
Answered

Input text Key down next frame

  • January 10, 2013
  • 1 reply
  • 3691 views

I am trying to figure out how to:

  1. A person inputs in the information in the input text
  2. They hit the enter key and
  3. it moves to the next screen.

It there a way to do this?

This topic has been closed for replies.
Correct answer Ned Murphy

You can use a listener to detect keyboard inouts and have a function that checks to see which entry was made.  The code for that is shown below.  As far as tying it into the textfield it depends what kind of condition you intend for it... maybe you just need a conditional around that line that checks if the input textfield contains anything.

stop();

var keyListener:Object = new Object();
Key.addListener(keyListener);

keyListener.onKeyDown = function(){
    if(Key.getCode() == 13) gotoAndStop(nextscreen);
}

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
January 10, 2013

You can use a listener to detect keyboard inouts and have a function that checks to see which entry was made.  The code for that is shown below.  As far as tying it into the textfield it depends what kind of condition you intend for it... maybe you just need a conditional around that line that checks if the input textfield contains anything.

stop();

var keyListener:Object = new Object();
Key.addListener(keyListener);

keyListener.onKeyDown = function(){
    if(Key.getCode() == 13) gotoAndStop(nextscreen);
}

Known Participant
January 11, 2013

Hi,

Thanks so much for answering.

When they click on the 15 it goes to the next screen where they put in a new number

When they put in the new number I need them to press the enter key and go to the next screen which would be 8 in

I am not sure how to handle the code you supplied as a input text object.

Thank so much for helping!

Ned Murphy
Legend
January 11, 2013

You don't handle the code as an input text object.  It is handled as a keyboard input event.  That code will go into whatever frame of the timeline where that screen is where you want it to work.  What you need to deal with is the action that gets taken when the Enter key is used.  In the code I show it is in the line...

gotoAndStop(nextscreen);

Where you have to specify what going to the next screen involves.  If it means moving to a new frame, then just replace "nextscreen" with the frame number it is going to.