Dynamic Text Box Questions: Easy Enough

Here are some questions:[list=1]
[]How would I set a certain dynamic text boxes color of the outer border and the inner background? I’ve seen many sites do this. I don’t like making a rectangle for it seperately.
[
]How would I make it so that, like for an input textbox, before you type anything in, it shows: Please Input a Name, and after you click in the input text box, before you start typing, the textbox clears the text.[/list]

  • Thanks

first question:

[AS]txt.backgroundColor = 0xFFFF00;//yellow bg
txt.borderColor = 0xFF0000;//red border[/AS]

where “txt” is the instancename of your textfield. You must select border in the propertypanel.

scotty(-:

You must select border in the propertypanel.

Yea, heh, I figured that much by now. Lol, thanks a lot. Now I just need the second question.


txt.text = "Please enter name"

2nd part i forget exact syntax but u need to use set foucs

second:
make your txtfield a movieclip (“tekst”)
txtfield variable =input
just type what you want in your txtfield and use this code: [AS]tekst.txt.backgroundColor = 0xFFFF00;
tekst.txt.borderColor = 0xFF0000;
tekst.onPress = function(){
tekst.input = “”;
}[/AS]

scotty

Nah, it doesn’t work. I put the input textbox into a movie clip. It’s instance name is tekst. It’s variable is input. And the actionscript on the first keyframe inside the MC is: [AS]tekst.text = “Please Enter Name”;
tekst.backgroundColor = 0x212121;
tekst.borderColor = 0x000000;
tekst.onPress = function() {
tekst.input = “”;
};


Why's it not working?

[AS]tekst.input = “Please Enter Name”;
tekst.txt.backgroundColor = 0x212121;
tekst.txt.borderColor = 0x000000;
tekst.onPress =function () {
tekst.input = “”;
}; [/AS]

first line you had tekst.text and you forgot the instancename of your txtfield

scotty:smirk:

//Bump

  • No man, you code doesn’t work. To make it have “Please Enter Your Name”, I took off the tekst part of the code. To make it have the colored textbox, I took off the .txt part of the code. And the last part definetly doesn’t work. Is onPress a function that’ll work for input textboxes?

  • Try to fix what I might be doing wrong:

tekst.text = "Please Enter Name";
tekst.backgroundColor = 0x212121;
tekst.borderColor = 0x000000;
tekst.onSetFocus = function() {
	this.text = "";
	this.onSetFocus = undefined;
};
//
var input = "Please Enter Name";
tekst.backgroundColor = 0x212121;
tekst.borderColor = 0x000000;
tekst.onSetFocus = function() {
	input = "";
	this.onSetFocus = undefined;
};

kode has beaten me.
here’s the fixed fla

Yea Alright Kode! Thanks a lot man!

You’re welcome, Sharif. :wink: