Search code examples
actionscript-3labelmxml

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


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!


Solution

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

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