hello,
i’m stuck with the following:
on click on “elements” i’m dynamically generating coloured boxes (all instances of the same symbol) and the colour of these boxes is applied through a colortransform. in the box there is a textfield and i want the the text to be colored according to the box color.
i mean, if the box is dark the text has to be white, and viceversa.
here’s the code:
var box_text:TextField = new TextField();
//textformat for black text
var dark_text:TextFormat = new TextFormat();
dark_text.color = 0x000000;
//textformat for white text
var white_text:TextFormat = new TextFormat();
white_text.color = 0xFFFFFF;
//inside the function
function generate_boxes (): void {
for (var k:int = 0; k <colours.length; k++) {
if (event.target == elements[k]) {
elements.index == colours.index;
var change_color:ColorTransform = boxx.transform.colorTransform;
change_color.color = colours[k];
boxx.transform.colorTransform = change_color;}
addChild(box_contenitore);
if (boxx.color >= "0xFFFF00") {box_text.setTextFormat(white_text)}
//else {box_text.setTextFormat(dark_text)};
}
it doesn’t throw an error, but the color is always the same. HELP!