开发者

Array, change color, as3

开发者 https://www.devze.com 2022-12-29 22:03 出处:网络
Thanks for the help Yesterday, but I have on more question. How can I change color of text on certain words?

Thanks for the help Yesterday, but I have on more question. How can I change color of text on certain words?

My animation plays the text animation of THIS SALE IS RED HOT!!! I want RED HOT it to be red. It seems the array can be indexed in such a way to switch the color from Blue to Red.

MY BANNER ADD

开发者_Python百科var myArray:Array = ["THIS","SALE","IS","RED HOT!!!",];
var tm:Timer = new Timer(500);
tm.addEventListener(TimerEvent.TIMER, countdown);
function countdown(event:TimerEvent) {
tx.text = myArray[(tm.currentCount-1)%myArray.length];
}
tm.start();
tx.textColor = 0x0000FF;

Cont...PSEUDO CODE

//var myArray:Array = ["This","Sale","is","RED HOT!!!",];
var spliceRedhot = myArray.splice(-1);
//trace(myArray[2]);
trace(spliceRedhot);
function mySplice(e:Event):void{
if (spliceRedhot = 4){
//Make RED HOT!!! red
tx.textColor = 0xFF0000;
}
else{
//Text is Blue again
tx.textColor = 0x0000FF;
}
}


use the textformat class. For instance to apply red from startindex to endindex:

 var format = new TextFormat()
 format.color = 0xff0000
 tx.setTextFormat(format,startindex,endindex)
0

精彩评论

暂无评论...
验证码 换一张
取 消