PDA

View Full Version : TextField Listener



jgreenwood
April 12th, 2009, 08:39 PM
I am trying to add some script so that when the user clicks inside an input text field it tells another object to play a certain frame. I take it it I need to add a listener to the text field but am not sure how to go about doing this. Thanks for any help.

bgflasher
April 14th, 2009, 05:18 AM
Hi.
If you are you using AS 3.0 try this one:

var tf:TextField = new TextField();
tf.type = TextFieldType.INPUT;
tf.border = true;
tf.x = 50;
tf.y = 50;
addChild(tf);

tf.addEventListener(MouseEvent.CLICK, doSomething);


function doSomething(e:MouseEvent):void{
trace("clicked");
}