How to change border color of input textbox?

  • DartHead
  • Beginner
  • Beginner
  • User avatar
  • Posts: 56
  • Loc: NYC

Post 3+ Months Ago

I am trying to create an input textbox that changes its border color when focus is given to it, like the search field on Macromedia's website in the upper left: http://macromedia.com/

Can anyone help? I'm using MX.

Tx!

Lance
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Well the macromedia.com site was done in Flash MX 2004, and every site i've seen that uses components from that version has this green border look (I can't say as I like it too much). I believe this is on by default, but im not sure since I don't use that version.

In Flash MX however you can use something like this...

Code: [ Select ]
//set your input textfield to have a border
myInputBox.border = true;
//set default border color (in this case grey)
myInputBox.borderColor = 0x999999;
//when textfield is focused
myInputBox.onSetFocus = function() {
    //change the border color to red
    this.borderColor = 0xFF0000;
};
//when focus is taken off of text field
myInputBox.onKillFocus = function() {
    //reset the border back to original grey color
    this.borderColor = 0x999999;
};
  1. //set your input textfield to have a border
  2. myInputBox.border = true;
  3. //set default border color (in this case grey)
  4. myInputBox.borderColor = 0x999999;
  5. //when textfield is focused
  6. myInputBox.onSetFocus = function() {
  7.     //change the border color to red
  8.     this.borderColor = 0xFF0000;
  9. };
  10. //when focus is taken off of text field
  11. myInputBox.onKillFocus = function() {
  12.     //reset the border back to original grey color
  13.     this.borderColor = 0x999999;
  14. };
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

That's very interesting. Fisrt time I even noticed it. THanks for the post (and the answer lostinbeta) -- I'll hav to remember this one.
  • DartHead
  • Beginner
  • Beginner
  • User avatar
  • Posts: 56
  • Loc: NYC

Post 3+ Months Ago

Thanks lostinbeta! That's exactly it.
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Glad I could help :)
  • DartHead
  • Beginner
  • Beginner
  • User avatar
  • Posts: 56
  • Loc: NYC

Post 3+ Months Ago

It was the onSetFocus that I couldn't figure out. Here is what I did with your code. It's not much, but it's a cool 5-cent effect.

http://lancemonotone.com/inputbox.htm

http://lancemonotone.com/inputbox.fla

Thanks again.

Lance
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Good Stuff... i'm glad to see you took the original concept and expanded on it to make your own thing. To be honest that is VERY rarely seen from people asking for help.
  • DartHead
  • Beginner
  • Beginner
  • User avatar
  • Posts: 56
  • Loc: NYC

Post 3+ Months Ago

Thanks. I'm trying to learn as much as I can. I'd be lost without the Flash community. I appreciate having people like you out there.
  • MayconSouza
  • Born
  • Born
  • MayconSouza
  • Posts: 1

Post 3+ Months Ago

Hi, this is very interting, but i try do this in a comboBox, and i donĀ“t have sucess...

Can you help me?

Tks
MayconSouza

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 9 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.