PDA

View Full Version : changing individual text character colors


diddles
11-08-2006, 04:25 PM
I have a variable containing a string e.g. myname="diddles";

I want to put this text into a new text field, but I want each character of the text to be a different color.

Does anyone have any pointers on this? Any help would be very much appreciated.

diddles
11-08-2006, 04:29 PM
Oops - just found this in the help! hopefully it will do the trick for me.

setTextFormat (TextField.setTextFormat method)

diddles
11-08-2006, 05:14 PM
did it! for anyone who might need thishere's the code:

colArray=["0xFF1200","0xFC42F5","0x42BBFB","0xFF5300","0x37C801","0x0A8DFF","0xFF720B"];

myname="diddles";
my_txt.text=myname;

colortext=function(){
for (var i=0;i<=myname.length;i++){

var fmt:TextFormat=new TextFormat();
var col=colArray[i];

fmt.color=col;


my_txt.setTextFormat(i,fmt);
}

}
colortext();