Solved

ActionScript2 - Key Listener

Posted on 2011-02-18
4
405 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
thank you
Regards,
Raul
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I have a Synology DS212+ NAS.  These are not only great for backup and normal NAS stuff, but also for delivering media throughout your home or LAN via DLNA.  I copied my whole audio collection from iTunes over to the box, but couldn't figure out how…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Viewers will learn how to use Macros for greater control over Rack parameters in Ableton Live. Group devices into a Rack by selecting them and pressing Command-G (Ctrl-G on PC): Control-click (Right Click on PC) a parameter to access pop-up menu, …
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now