Groups | Blog | Home
all groups > flash actionscript > march 2006 >

flash actionscript : setting the text color according to the background color


athomas32
3/27/2006 11:03:48 PM
i have buttons set up as movie clips. the background color is determined by
input from an xml file. if the colors are dark, i would like the text to be
white. I am not sure how to go abolut this. Any ideas???
shottogan
3/27/2006 11:24:14 PM
have the text set to be

R = 255 - xmlR;
G = 255 - xmlG;
B = 255 - xmlB;

that will make it the opposite of whatever the background is set to be. if you
need the text to keep the background's tint but just be brighter / darker, do:

(example for R, repeat with other colors)

if (xmlR<=100){
R = xmlR + 155;
}else if (xmlR>100 && xmlR<150){
R = xmlR + 106;
}else if (xmlR>=150){
R = xmlR - 150;
}
shottogan
3/28/2006 12:25:56 AM
checkout:

http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.ht
m?context=LiveDocs_Parts&file=00002073.html
to learn your Color commands.

how are you setting your bkg? if you cant figure it out, let me see your code,
AddThis Social Bookmark Button