# Change Text Color by AS

**URL:** <https://forum.kirupa.com/t/change-text-color-by-as/35593>\
**Category:** flash\
**Created:** [November 15, 2003, 8:49pm UTC](https://forum.kirupa.com/t/change-text-color-by-as/35593 "2003-11-15T20:49:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nasier](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@Nasier](https://forum.kirupa.com/u/Nasier)\
**Post date:** [November 15, 2003, 8:49pm UTC](https://forum.kirupa.com/t/change-text-color-by-as/35593/1 "2003-11-15T20:49:23Z")

</div>

I’ve a button with a dynamic textfield inside it. Now I want to change the color of this text by AS. How can I do this? Can it be done?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 15, 2003, 11:04pm UTC](https://forum.kirupa.com/t/change-text-color-by-as/35593/2 "2003-11-15T23:04:22Z")

</div>

First off, you’ll have some problems targetting the text field inside the button, so use a movie clip instead. Then you can use its [font=courier new]textColor[/font] property, or the [font=courier new]TextFormat[/font] object to define the text color. 🙂

Examples:

```auto
this.createTextField("my_txt", 0, 0, 0, 0, 0);
my_txt.autoSize = "left";
my_txt.textColor = 0xCC0000;
my_txt.text = "Hello!";
//
this.createTextField("my_txt", 0, 0, 0, 0, 0);
my_txt.autoSize = "left";
my_txt.text = "Hello!";
var my_fmt = new TextFormat();
my_fmt.color = 0xcc0000;
my_txt.setTextFormat(my_fmt);

```
