1

我是编程新手,我只是想将某个属性添加到 ActionScript 2.0 中的倒数计时器脚本中。

一切看起来都很好并且工作正常,唯一缺少的是我想在数字之间添加更多的文本间距(所以我可以在每个数字后面添加图片(阴影))。

谁能帮我指出正确的方向,将 TextSpacing 属性添加到我的代码中,我不太熟悉 actionscript 语法:

this.onEnterFrame = function()
{
 var today:Date = new Date();
 var currentYear = today.getFullYear();
 var currentTime = today.getTime();
 var targetDate:Date = new Date(currentYear,8,4);
 var targetTime = targetDate.getTime();
 var timeLeft = targetTime - currentTime;
 var sec = Math.floor(timeLeft/1000);
 var min = Math.floor(sec/60);
 var hours = Math.floor(min/60);
 var days = Math.floor(hours/24);
 sec = String(sec % 60);
 if(sec.length < 2){
  sec = "0" + sec;
 }
 min = String(min % 60);
 if(min.length < 2){
  min = "0" + min;
 }
 hours = String(hours % 24);
 if(hours.length < 2){
  hours = "0" + hours;
 }
 days = String(days);
 if(timeLeft > 0 ){
  var counter:String = days + ":" + hours + ":" + min + ":" + sec;
  time_txt.text = counter;

 }else{
  trace("TIME'S UP");
        var newTime:String = "00:00:00:00";
        time_txt.text = newTime;
        delete (this.onEnterFrame);
 }
} 
4

1 回答 1

1
// create text format
var format:TextFormat = new TextFormat();
format.letterSpacing = 10;

// set text format
time_txt.setTextFormat(format);

为了性能,我会在你的 onEnterFrame 循环之外做,因为你只需要做一次。

更多信息...

http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00001626.html http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content =00001650.html

于 2013-07-18T23:49:58.813 回答