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

KeyboardEvent Enter Key

New Here ,
Apr 12, 2013 Apr 12, 2013

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

TOPICS
ActionScript
1.3K
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
Community Expert ,
Apr 12, 2013 Apr 12, 2013

stage.addEventListener(KeyboardEvent.KEY_DOWN,keydownF);

function keydownF(e:KeyboardEvent):void{

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

yourtextarea.text=yourtextinput.text;

}

}

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 ,
Apr 12, 2013 Apr 12, 2013

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   

    }
}

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 ,
Apr 12, 2013 Apr 12, 2013

Appreciate your help guys. Tested the code and worked nicely.

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 ,
Apr 12, 2013 Apr 12, 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 ,
Jul 30, 2019 Jul 30, 2019

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){
         /

    }

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
Community Expert ,
Jul 30, 2019 Jul 30, 2019

use gotoAndStop(1) or gotoAndPlay(1)

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 ,
Jul 30, 2019 Jul 30, 2019

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.

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
Community Expert ,
Jul 30, 2019 Jul 30, 2019

it won’t stop code that’s executing but it will move the playhead to frame 1.  it won’t reset anything

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 ,
Jul 30, 2019 Jul 30, 2019

what about linking a key to the rewind function in the flash player interface?

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
Community Expert ,
Jul 30, 2019 Jul 30, 2019
LATEST

i know of no such thing

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 ,
Jul 30, 2019 Jul 30, 2019

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?

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