Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change color of textbox

Status
Not open for further replies.

MJB3K

Programmer
Jul 16, 2004
524
GB
Hi, how do you change the background color of a textbox when a user clicks their mouse in it? or it gets focus?

any ideas??


Regards,

Martin

Gaming Help And Info:
 
Here's an example:

Code:
textBox.onSetFocus = function() {
	textBox.background = true;
	textBox.backgroundColor = 0xff0000;
};

Hope it helps!

Wow JT that almost looked like you knew what you were doing!
 
yea thanks :)

how do you make it change back when it loses focus?? like change to another box for example or click the main movie frame.

Regards,

Martin

Gaming Help And Info:
 
Code:
textBox.onSetFocus = function() {
	textBox.background = true;
	textBox.backgroundColor = 0xff0000;
};

textBox.onKillFocus = function(){
	textBox.backgroundColor=0xffffff;
}

Hope it helps!

Wow JT that almost looked like you knew what you were doing!
 
yea thats gd thnx:)

is there anyway of making it so i dont have to type it out each time for a different textbox??

I have about 5 textboxes and don't want to type it out 5 differnt times, harder to update.

is it an array or something??

any ideas??


Regards,

Martin

Gaming Help And Info:
 
Sure you could do a global function for it.

Code:
//pass in the instance name of the text box

_global.setTextBox = function(textBox,mode){
   if(mode == "on"){
      textBox.background = true;
      textBox.backgroundColor = 0xff0000;
   }else if(mode == "off"){
      textBox.backgroundColor = 0xffffff;
   }
}

textBoxName.onSetFocus = _global.setTextBox("textBoxInstanceName","on");
textBoxName.onKillForcus = _global.setTextBox("textBoxInstanceName","off");

You could also do it with an array.

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top