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

Input text Key down next frame

New Here ,
Jan 10, 2013 Jan 10, 2013

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?

TOPICS
ActionScript
3.4K
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 , Jan 10, 2013 Jan 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(nextscre

...
Translate
LEGEND ,
Jan 10, 2013 Jan 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);
}

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
New Here ,
Jan 11, 2013 Jan 11, 2013

Hi,

Thanks so much for answering.

Capture.PNG

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

Capture2.PNG

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

Capture3.PNG

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

Thank so much for helping!

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
LEGEND ,
Jan 11, 2013 Jan 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.

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
New Here ,
Jan 14, 2013 Jan 14, 2013

I am assuming 13 is the enter key?

Do I need to add the input name in the new object.

Sorry I not every good at writing code.

I put the code in the frame and nothing happen

YOUR CODE:

stop();

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

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

MY CODE:

stop();

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

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

Thanks so much for your help!

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
LEGEND ,
Jan 14, 2013 Jan 14, 2013

If you want to know which keys have which codes, add the line: trace(Key.getCode());  as the first line of that function.  It's a handy line to have.

No, putting the ft in the Object declaration won't do anything for you.  All you should need to do is enter some text (or not) and then hit the Enter key.  What you might not be dealing with properly is the line I said you need to attend to...

gotoAndStop(nextscreen);

That line dictates what pressing the Enter key will end up doing.  If you have not defined 'nextscreen' in any way, it will do nothing.  Since I do not know what you mean when you say pressing Enter will make it move "to the next screen",  I can only provide a generically written bit of code to describe what it might do.

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
New Here ,
Jan 14, 2013 Jan 14, 2013

capture4.PNG

It is not working for some reason? When I publish the cursor stays in the same place.

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
LEGEND ,
Jan 14, 2013 Jan 14, 2013

Put a trace in that function to see if the function is being called when the keyboard is used.

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
New Here ,
Jan 14, 2013 Jan 14, 2013

I did and nothing showed up? I assuming is should show up in the output or compiler error area?

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
New Here ,
Jan 14, 2013 Jan 14, 2013

It runs in a shell. Could this be the issue?

Capture5.PNG

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
New Here ,
Jan 14, 2013 Jan 14, 2013

The tab function works

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
LEGEND ,
Jan 14, 2013 Jan 14, 2013

When you test in Flash, in the Flash Player you should select the Disable Keyboard Shortcuts option found under the Control option in the top menubar.

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
New Here ,
Jan 14, 2013 Jan 14, 2013

I have the option when ctrl enter to publish without the main navigation. If I publish and run through main navigation it opens it full screen mode without the option.

The publish without the navigation only gives me the debug of 0.

  Text:

0

After I change the text is does not give me anything when I press enter on the keyboard.

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
New Here ,
Jan 14, 2013 Jan 14, 2013

Do you think it is because I have to use ActionScript 1.0?

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
LEGEND ,
Jan 14, 2013 Jan 14, 2013

That could be the problem.  If you have to use AS1, are you able to publish for Flash Player 6?  That is when the Key class came into being.

Why can't you publish for AS2?  Do you have a vewrsion of Flash that precedes Flash MX?

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
New Here ,
Jan 14, 2013 Jan 14, 2013

The program was orginally written AS1 and they do not want to pay to update it -- just the content.

Here are the settings I am using.

Capture7.PNG

Thanks again so much for you help.

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
LEGEND ,
Jan 14, 2013 Jan 14, 2013

While the documentation would have me professing that the code I provided should work for AS1/FP6+, my own testing of it shows it ain't the case.  So here's what you can try for AS1...

If you already have a button that would also move to the next screen, the it probably has code like the following attached to it....

on(release){

      gotoAndStop(10);

}

If you modify it to what follows you should get the Enter key functionality you are after...

on(release, keyPress "<Enter>"){

      gotoAndStop(10);

}

If you do not have a button that does it already, create one and hide it somehow so it can't be interacted with and plant the code I just showed on it.

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
New Here ,
Jan 14, 2013 Jan 14, 2013

OMG it worked. You are awsome! Thanks so much So very happy!

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
LEGEND ,
Jan 14, 2013 Jan 14, 2013

You're welcome

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
New Here ,
Aug 16, 2013 Aug 16, 2013

I have a question, I want to make typing games, but I don`t know how to make it. I need code for input text in Actionscript 3.0, and moves to the frame. what is the Code?

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
LEGEND ,
Aug 17, 2013 Aug 17, 2013
LATEST

Start your own posting in the AS3 forum and provide more detail.

http://forums.adobe.com/community/flash/flash_actionscript3?view=discussions

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