Copy link to clipboard
Copied
On stage i have a button, TextInput and a TextArea component. I want the user to add some content in the TextInput field and when Enter is clicked on the Keyboard the content will be transferred and displayed in the TextArea. How do i do this? I know the keyCode == Keyboard.ENTER is to recognize when enter is pressed but to do this is more complicated.
Thank You
Copy link to clipboard
Copied
stage.addEventListener(KeyboardEvent.KEY_DOWN,keydownF);
function keydownF(e:KeyboardEvent):void{
if(e.keyCode==Keyboard.ENTER){
yourtextarea.text=yourtextinput.text;
}
}
Copy link to clipboard
Copied
Assign a listener for a KeyboardEvent and if the event indicates the Enter key was used, write the text to the textarea.
stage.addEventListener(KeyboardEvent.KEY_UP, writeText);
function writeText(event:KeyboardEvent):void {
if(event.keyCode == Keyboard.ENTER){
// write the text to the textarea
}
}
Copy link to clipboard
Copied
Appreciate your help guys. Tested the code and worked nicely.
Copy link to clipboard
Copied
You're welcome
Copy link to clipboard
Copied
Hello Ned,
could i take the code you gave below:
stage.addEventListener(KeyboardEvent.KEY_UP, writeText);
function writeText(event:KeyboardEvent):void {
if(event.keyCode == Keyboard.ENTER){
// write the text to the textarea
}
}
and change it to cause the file I have to reset back to frame 1 upon a key press of enter or 1 etc?
stage.addEventListener(KeyboardEvent.KEY_UP, goto (1));
function goto(event:KeyboardEvent):void {
if(event.keyCode == Keyboard.ENTER){
/
}
Copy link to clipboard
Copied
use gotoAndStop(1) or gotoAndPlay(1)
Copy link to clipboard
Copied
will that allow me to interrupt the sequence though in the middle of it and reset the scene to frame 1?
The context of this may help clarify, I have a large paragraph of text that I have broken into keyframes (1letter/space per keyframe)
as the actor taps the keys and the playhead moves forward "typing out my paragraph", I would like to assign a key for the props person that will allow them to stop the scene if there is mistake and quickly start anew without having to keypress 352 times to get to the end of the paragraph.
Copy link to clipboard
Copied
it won’t stop code that’s executing but it will move the playhead to frame 1. it won’t reset anything
Copy link to clipboard
Copied
what about linking a key to the rewind function in the flash player interface?
Copy link to clipboard
Copied
i know of no such thing
Copy link to clipboard
Copied
the swf isn't animate beyond the playhead moving through 352 keyframes, each with another letter added to create a document. if not touched, it just sits dormant. there is no way to script goto(1) on enter key event?
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more