我是编程新手,我只是想在ActionScript 2.0中向Countdown计时器脚本添加某个属性。
一切看起来很好并且工作正常,唯一缺少的是,我想在数字之间添加更多的文本间距(所以我可以在每个数字后面添加一个图片(阴影))。
有人可以帮我指点向我的代码添加TextSpacing属性的正确方向,我对动作脚本的语法并不熟悉:
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);
}
}
答案 0 :(得分: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