# \[FMX\]text field, onSetFocus and onKillFocus

**URL:** https://forum.kirupa.com/t/fmx-text-field-onsetfocus-and-onkillfocus/48510
**Category:** flash
**Created:** [April 14, 2004, 8:55am UTC](https://forum.kirupa.com/t/fmx-text-field-onsetfocus-and-onkillfocus/48510 "2004-04-14T08:55:57Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [April 14, 2004, 8:55am UTC](https://forum.kirupa.com/t/fmx-text-field-onsetfocus-and-onkillfocus/48510/1 "2004-04-14T08:55:57Z")

</div>

I’m making a form and i want to set a backgroundColor for the textfields onSetFocus and that the backgroundColors dissapear again onKillFocus. So far I have this code

```auto
naam.onSetFocus = function(){
 this.background = true;
 this.backgroundColor = 0xdddddd;
}
mail.onSetFocus = function(){
 this.background = true;
 this.backgroundColor = 0xdddddd;
} 
naam.onKillFocus = function() {
 naam.background = false
};
mail.onKillFocus = function() {
 mail.background = false;
};

```

but to me it seems that there must be a way to combine all this lines of code into one single function or at least two one for the setFocus and one for the killFocus.

Somebody who know how to this?
