Solved

ActionScript2 - Key Listener

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

861 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