Clearing input text feilds when clicked on in Flash (AS 2.0)
Posted
by rickstyphilis
on Stack Overflow
See other posts from Stack Overflow
or by rickstyphilis
Published on 2010-03-17T11:51:34Z
Indexed on
2010/03/17
13:01 UTC
Read the original article
Hit count: 303
I have a problem where I want a text field that by default has the word NAME in it, to become empty when a user clicks on it.
The text field has the instance name 'nam' and is inside a movie with the instance name 'input_text'.
I've searched around and found samples of code where everyone keeps suggesting this:
textboxinstancename.onSetFocus = function() {
textboxinstancename.text = "";
};
should work. It seems to work for everyone else but me.
I've tried using the following on the first frame of the 'input_text' movie with no luck:
this.input_text.nam.onSetFocus = function() {
this.input_text.nam.text = ""
}
I've tried putting this on the first frame of the scene, again with no result:
_root.input_text.nam.onSetFocus = function() {
_root.input_text.nam.text = ""
}
I've tried this in the same manner as the last respectively with both 'this' on the instance and '_root' on the scene (denoted by x):
x.input_text.nam.onSetFocus = function() {
if (x.input_text.nam.text == "NAME") {
x.input_text.nam.text = "";
}
};
Still no luck. Can anyone tell me what I might be doing wrong?
© Stack Overflow or respective owner