How can you change a Label's color at runtime in ActionScript 3.0?

Panzercrisis picture Panzercrisis · Jun 21, 2012 · Viewed 7.8k times · Source

I get the following error:

1119: Access of possibly undefined property color through a reference with static
type mx.controls:Label.

The thing about that is that, in the MXML, color is an attribute of Label. But if I try to say something like:

lblUpgrade.color = "#000000";

it throws this error. I've been trying to find a work-around for the last 45 minutes. How can I set this at runtime? Thanks!

Answer

NoobsArePeople2 picture NoobsArePeople2 · Jun 21, 2012

Label does not have a color property, rather it has a color style which can be set like so:

lblUpgrade.setStyle("color","#000000");