Having a bit of trouble setting label colors in a for loop
This works as expected:
label1.styleName = "myStyle";
However this does not:
for (var j:int = 0; j < labels.length; j++) {
labels[j].styleName = "myStyle";
}
When I trace the style I get the style name, but nothing changes visually, as it does in the first example.
I’ve tried other things such as:
(labels[j] as Label).setStyle('color', 0xFFFFFF); // Null object reference
And all the variants I could think of on that….setStyle(), as LabelItemRenderer…
Any thoughts?
Ah, for anyone else who happens to have this unusual problem, I had added the elements to the array wrong….
I had added them all in a loop without referencing with the ‘this’ keyword…. Nothing wrong with the code above, just the array. Derp!