Copy link to clipboard
Copied
I am trying to figure out how to:
It there a way to do this?
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
Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
It is not working for some reason? When I publish the cursor stays in the same place.
Copy link to clipboard
Copied
Put a trace in that function to see if the function is being called when the keyboard is used.
Copy link to clipboard
Copied
I did and nothing showed up? I assuming is should show up in the output or compiler error area?
Copy link to clipboard
Copied
It runs in a shell. Could this be the issue?
Copy link to clipboard
Copied
The tab function works
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Do you think it is because I have to use ActionScript 1.0?
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Thanks again so much for you help.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
OMG it worked. You are awsome! Thanks so much So very happy!
Copy link to clipboard
Copied
You're welcome
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Start your own posting in the AS3 forum and provide more detail.
http://forums.adobe.com/community/flash/flash_actionscript3?view=discussions
Find more inspiration, events, and resources on the new Adobe Community
Explore Now