# setFocus color

**URL:** <https://forum.kirupa.com/t/setfocus-color/259917>\
**Category:** flash\
**Created:** [May 10, 2008, 3:34am UTC](https://forum.kirupa.com/t/setfocus-color/259917 "2008-05-10T03:34:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ToubMor](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/toubmor/32/3422_2.png) [@ToubMor](https://forum.kirupa.com/u/ToubMor)\
**Post date:** [May 10, 2008, 3:34am UTC](https://forum.kirupa.com/t/setfocus-color/259917/1 "2008-05-10T03:34:45Z")

</div>

Hi there,  
Im wondering if its possible to change the setFocus color from black to a different color.  
Ive seen it on the web some where but i cant remember where??? does somebody know about this

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [May 10, 2008, 9:51pm UTC](https://forum.kirupa.com/t/setfocus-color/259917/2 "2008-05-10T21:51:48Z")

</div>

Not sure what you mean…if you want to change the colour/border of a textfield once it’s got the focus you can use onSetFocus and onKillFocus as per the following quick code:

```auto
// set up initial textfields
this.createTextField("first_txt", 1, 10, 10, 300, 20);
first_txt.border = true;
first_txt.type = "input";
first_txt.text = "This is textfield 1";
this.createTextField("second_txt", 2, 10, 40, 300, 20);
second_txt.border = true;
second_txt.type = "input";
second_txt.text = "This is textfield 2";
// set text and border colours to default values when focus is killed
first_txt.onKillFocus = second_txt.onKillFocus = function (newFocus:Object) {
	this.borderColor = this.textColor = 0x000000;
};
// set text and border colours to red when textfield has the focus
first_txt.onSetFocus = second_txt.onSetFocus = function (oldFocus:Object) {
	this.borderColor = this.textColor = 0xFF0000;
};

```

If you mean changing the colours when you select text, you can try the approach given here:  
[http://ericlin2.tripod.com/select/selectt.html](http://ericlin2.tripod.com/select/selectt.html)  
or experiment with the AS 2 class from here:  
[http://theflashblog.com/?p=173](http://theflashblog.com/?p=173)

Finally, if you mean removing the yellow border that can appear around objects that have focus, set the global property \_focusrect = false; to turn it off. If you’re planning an application in Flashlite 2.0, you can also change the default \_focusrect colour using fscommand2("SetFocusRectColor, \<red\>, \<green\>, \<blue\>); where red, green and blue are values between 0-255.

Hope that all helps.
