# AS3: changing text format according to container color

**URL:** https://forum.kirupa.com/t/as3-changing-text-format-according-to-container-color/314368
**Category:** flash
**Created:** [September 26, 2010, 2:47pm UTC](https://forum.kirupa.com/t/as3-changing-text-format-according-to-container-color/314368 "2010-09-26T14:47:58Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![elliria](https://avatars.discourse-cdn.com/v4/letter/e/f04885/32.png) [@elliria](https://forum.kirupa.com/u/elliria)
#### Post date: [September 26, 2010, 2:47pm UTC](https://forum.kirupa.com/t/as3-changing-text-format-according-to-container-color/314368/1 "2010-09-26T14:47:58Z")

</div>

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:

```auto

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!
