【问题标题】:Array, change color, as3数组,改变颜色,as3
【发布时间】:2010-05-12 17:47:14
【问题描述】:

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

我的动画播放的是THIS SALE IS RED HOT的文字动画!!!我希望 RED HOT 它是红色的。似乎可以通过将颜色从蓝色切换到红色的方式对数组进行索引。

我的横幅添加

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;

续...伪代码

//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;
}
}

【问题讨论】:

    标签: flash actionscript-3


    【解决方案1】:

    使用 textformat 类。例如将红色从 startindex 应用到 endindex:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-01
      • 1970-01-01
      • 2018-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多