Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


ActionScript2 - Key Listener

Posted on 2011-02-18
Medium Priority
Last Modified: 2012-06-21
Hi experts,

im using a non Adobe environment (Selteco-Alligator) which is AS supportive but very limited in features. For my small project i need to add "CR" or "\n" to a text field when the user press the "ENTER" key. To create the textfield i use the following code

this.createTextField("ht", 1, 10, 10, 200, 40);
var my_fmt:TextFormat = new TextFormat();
my_fmt.font="Lamebrain BRK";
my_fmt.color = 0xff0000;
my_fmt.underline = false;
ht.multiline = true;
ht.wordWrap = true;
ht.focusEnabled = true;

Open in new window

Now i need to add a keyListener which should add "\n" to the ht.text...something like  ht.text = ht.text.concat ("\n") when the user press ENTER.

Practically i want to make a simple text editor to fill a send mail form. Alligator does not have implemented "User paragraph"; i mean the user cant start a new line by pressing ENTER. A new line is started only when the previous line reach the right edge of the textfield.

As im new in AS and in flash based web design i got stucked in implementing a keyListener.

A small snippet or code will be highly appreciated (and paid  ;o) )

Question by:raulmonda
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 17

Expert Comment

ID: 34931245
There is an error in the line 9:
Change that to
ht.type = "input";

That should do the work.

Warm Regards
Deepanjan Das

Author Comment

ID: 34931349
Thank you.

ok, change it, but still dont work. what i need is a snippet for a key listener.

LVL 17

Accepted Solution

deepanjandas earned 2000 total points
ID: 34931607
But just pasting your code, I can do that, there nothing special you need to do to go to next line. Just pressing the return key the cursor goes to the next time in your code.

Warm Regards
Deepanjan Das

Author Closing Comment

ID: 34932308
thank you

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question