Solved

ActionScript2 - Key Listener

Posted on 2011-02-18
4
409 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

How our DevOps Teams Maximize Uptime

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

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 …
Keep your audience engaged and get the most out of your next presentation with these quick Prezi tips.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

685 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