Monday, February 15, 2010

Learn Actionscript Techniques - Change Text Color in Runtime




import flash.text.TextFormat;

var format:TextFormat = new TextFormat();
var r:Number = 0x000000;
var g:Number = 0x000000;
var b:Number = 0x000000;
var red:Number;
var green:Number;
var blue:Number;

addEventListener(Event.ENTER_FRAME,changeColor);

function changeColor(evt:Event) {
red = 127*(1+Math.cos(r += .03));
green = 127*(1+Math.cos(g += .06));
blue = 127*(1+Math.cos(b += .02));
var myColor = red << 16 | green << 8 | blue;
format.color = myColor;
colorText.setTextFormat(format);
}

No comments:

Post a Comment

Thirukkural