PDA

View Full Version : textField question


timothye
03-31-2004, 05:05 PM
i have a input textField . and i have "name" typed in the textField ..
is it possible for this textField , when i click on it to make the existing text disappear when i click in the textField .then typ in the info ?
i have been trying to do this out of pure couriosity..here is my code that i dont know what im doing here ..:D

//name here in dynamic textField
my_txt.text = "Name here";
my_txt.onChanged = function(txt) {
trace(txt._name+"changed");
my_txt.text = "";
};
my_listener = new Object();
my_listener.onChanged = function(txt) {
my_txt.text = my_txt.text;
trace(txt._name+"new text");
};
my_txt.addListener(my_listener);

this basically clears the text Field . but then doesnt receive any text typed in after the onChanged <-
thanks for anysuggestions

jubei
03-31-2004, 10:37 PM
It's not letting you type anything in because onChanged is called every time something is typed in, and clearing the text box.

Try onSetFocus instead, which is only triggered when you click the box. All you really need is

my_txt.text = "Name here";
my_txt.onSetFocus = function() {
my_txt.text = "";
};

timothye
03-31-2004, 11:00 PM
hey that is what i had going in the first place .. but the onyl problem with that is it doesnt display "name here" its blank as soon as you enter that frame .. not unless i am doing something wrong ..

jubei
03-31-2004, 11:05 PM
I'm not sure. I tested it, and it worked fine for me. Give it a go.. make a new file, create your text box, and add that code to the frame, then export it. If that doesn't work for you, post the .fla somewhere, because that's exactly what I did, and it seemed fine

timothye
03-31-2004, 11:22 PM
got it !!
thanks for you help .. very much appreciated ..

jubei
03-31-2004, 11:32 PM
No worries :)