如何在ActionScript 3.0中在运行时更改Label的颜色?

Pan*_*sis 5 label mxml actionscript-3

我收到以下错误:

1119: Access of possibly undefined property color through a reference with static
type mx.controls:Label.
Run Code Online (Sandbox Code Playgroud)

关于这一点的是,在MXML中,color是Label的一个属性.但如果我试着说:

lblUpgrade.color = "#000000";
Run Code Online (Sandbox Code Playgroud)

它抛出了这个错误.我一直试图找到最后45分钟的解决方法.我怎样才能在运行时设置它?谢谢!

Noo*_*le2 11

Label没有color属性,而是具有可以这样设置的颜色样式:

lblUpgrade.setStyle("color","#000000");
Run Code Online (Sandbox Code Playgroud)


Bar*_*klı 5

在as3中可以像这样访问样式

lblUpgrade.setStyle("color","#000000");
Run Code Online (Sandbox Code Playgroud)