Reputation: 233
The theme question sais it all.
I have an input text-field on the stage that has some text describing text in it before the user types anything. Now, how do I clear this text when the user focuses on (clicks) the field?
Upvotes: 1
Views: 19003
Reputation: 4209
important: userName is MovieClip and this movieClip's inside ı have TextField which name is txt.
userName.addEventListener(FocusEvent.FOCUS_IN, clearBox);
function clearBox(evt:FocusEvent):void
{
userName.text="";
}
Upvotes: 1
Reputation: 1860
Try this Code
txtMessage.addEventListener(FocusEvent.FOCUS_IN, clearBox);
function textclearBox(FocusEvent)
{
txtUser.text="";//To Clear the Text Box
}
Upvotes: 3
Reputation: 58067
This should do it. (Although, my AS3 is a bit rusty.)
textbox.addEventListener(FocusEvent.FOCUS_IN, clearBox);
function clearBox(e:FocusEvent){
textbox.setText("");
}
Upvotes: 1
Reputation: 27045
Listen for the FocusEvent.FOCUS_IN
event on your textfield and clear it once that fires.
http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/events/FocusEvent.html
Upvotes: 4