Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change font-color of TextField inside MovieClip

I've a problem to change the font-color of a TextField after it has been added as a child to a MovieClip.

My code:

var btn:MovieClip = new MovieClip();        
// other code for button

var tf:TextFormat = new TextFormat();
tf.size = 12;
tf.bold = true;
tf.font = "Arial"
tf.color = 0x000000;

var capt:TextField = new TextField();
capt.defaultTextFormat = tf;
capt.width = 200;
capt.height = 50;
capt.text = "Test";
capt.y = 20;
capt.x = 20;
capt.border = false;
capt.selectable = false;    

btn.addChild(capt);

// .....

How can I Change the font-color after the last line?

like image 602
Kesandal Avatar asked Oct 22 '25 16:10

Kesandal


1 Answers

It sounds like you're looking for TextField.setTextFormat(). You can either adjust your original TextFormat or just make a whole new one.

tf.color = 0xFF0000;
capt.setTextFormat(tf);
like image 53
David Mear Avatar answered Oct 24 '25 16:10

David Mear



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!