Change Text Color by AS

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?

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. :slight_smile:

Examples:

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);