数组,改变颜色,as3

时间:2010-05-12 17:47:14

标签: flash actionscript-3

感谢昨天的帮助,但我还有更多问题。如何更改某些单词的文字颜色?

我的动画播放本次销售的文字动画很红!我想RED HOT它是红色的。似乎可以通过这种方式将数组编入索引,将颜色从蓝色切换为红色。

MY BANNER ADD

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;

续...... 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;
}
}

1 个答案:

答案 0 :(得分:3)

使用textformat类。例如,将startindex中的红色应用于endindex:

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