怎么样用FLASH做一个60秒倒计时

来源:百度知道 编辑:UC知道 时间:2024/06/10 17:07:56
RT

60秒倒计时,[可选最后10(9--0)秒带声音(你需要在flash同文件夹下放一个1.mp3声音文件,声音半秒即可);]
该flash1桢2个图层
图层1放脚本如下:
txt = 59;
var song0 = new Sound();
datas = new Date();
time = int(datas.getSeconds());
function djs() {
_root.onEnterFrame = function() {
datas = new Date();
newtime = int(datas.getSeconds());
if (newtime != time) {
txt--;
// if (txt<10&&txt>=0) {
// song0.loadSound("1.mp3", true);
// txt2 = Math.floor(song0.duration/1000)+"sec";
// }
if (txt<0) {
txt = 59;
}
time = newtime;
}
};
}
图层2放一个动态文本,文本框50X50大小即可,变量名txt;
再放一个开始按钮,按钮下放脚本如下:
on(press){
djs()
}

如果你是用的FLASH CS3,那么在第一帧添加如下代码:
var txt:TextField=new TextField()
addChild(txt)
txt.x=100
txt.y=100
var timer:Timer=new Timer(1000,60)
timer.addEventListener(TimerEvent.TIMER,loop)
timer.start()
function loop(e:Timer