Solved

ActionScript2 - Key Listener

Posted on 2011-02-18
4
407 Views
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.size=28;
my_fmt.bold=true;
my_fmt.italic=true;
my_fmt.color = 0xff0000;
my_fmt.underline = false;
my_fmt.type="input";
ht.setTextFormat(my_fmt);
ht.multiline = true;
ht.wordWrap = true;
ht._visible=true;
ht.focusEnabled = true;
ht.text="first";

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

Regards,
Raul
0
Comment
Question by:raulmonda
  • 2
  • 2
4 Comments
 
LVL 17

Expert Comment

by:deepanjandas
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
0
 

Author Comment

by:raulmonda
ID: 34931349
Thank you.

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

regards,
Raul
0
 
LVL 17

Accepted Solution

by:
deepanjandas earned 500 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
0
 

Author Closing Comment

by:raulmonda
ID: 34932308
thank you
Regards,
Raul
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

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…
Tired of waiting for your show or movie to load?  Are buffering issues a constant problem with your internet connection?  Check this article out to see if these simple adjustments are the solution for you.
Viewers will learn the basics of creating custom device Racks in Ableton Live. Place instrument(s) and effects onto a track, and select them all by holding the Shift key and clicking on the device title bars: Group them by typing Command-G (Ctrl-G…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

785 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