# TextField text color changing (not animated)

**URL:** https://forum.kirupa.com/t/textfield-text-color-changing-not-animated/287014
**Category:** flash
**Created:** [April 24, 2009, 3:41pm UTC](https://forum.kirupa.com/t/textfield-text-color-changing-not-animated/287014 "2009-04-24T15:41:26Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![redelite](https://avatars.discourse-cdn.com/v4/letter/r/dc4da7/32.png) [@redelite](https://forum.kirupa.com/u/redelite)
#### Post date: [April 24, 2009, 3:41pm UTC](https://forum.kirupa.com/t/textfield-text-color-changing-not-animated/287014/1 "2009-04-24T15:41:26Z")

</div>

Say I have a class that extends TextField and I want to have it set a default text color to black (0x000000) when initiated. Easy enough. But then say, when the XML finishes loading and the user has decided to change the color of that textfield to red (0xFF0000), what would be the easiest way to change the text color of that field?

The only way I can think to do it is to change the textformat color via public method? Would this be correct or is there an easier way?

Thanks ahead! 🍺:pac:

Small example:

```auto

var my_color:uint = 0xFF0000;
var t:MyTextBox = new MyTextBox();
t.setTextColor(my_color);

class MyTextBox extends TextField {
  _fmt:TextFormat;
  _userColor:uint = null;

  function MyTextBox() {
    init();
  }

  private function init():void {
    setProperties();
    setFormat();
            
    this.text = "Default Text";
  }

  private function setProperties():void {
    this.multiline = false;
    this.wordWrap = false;
    this.width = 150;
    this.height = 24;
    this.x = 20;
    this.y = 20;
  }

  private function setFormat():void {
    _fmt = new TextFormat(new LucidaSansR().fontName, 10, 0xFFFFFF, null, null, null, null, null, "center");

    this.defaultTextFormat = _fmt;
  }

  public function setTextColor(new_color:uint):void {
    _userColor = new_color;

    // What would I put here, another text format?????
  }
}

```
