flash时钟代码
我文档做好了,就是不知道代码怎么打,谁能告诉我啊,最好是传个工程文件给我就好了,不要数字时钟哦,要有指针转的那种,谢谢了!...
我文档做好了,就是不知道代码怎么打,谁能告诉我啊,最好是传个工程文件给我就好了,不要数字时钟哦,要有指针转的那种,谢谢了!
展开
1个回答
展开全部
//新建fla文档(as2.0),复制以下代码到第一帧,ctrl+enter 即可看到效果
var timeText:TextField = this.createTextField("time", 0, 0, 0, 100, 20);
function init() {
hitTime = 0;
beginRunTime = 0;
totalRunTime = 0;
timeText.text = "00:00:00";
}
init();
onMouseDown = function () {
switch (hitTime) {
case 0 :
//开始计时
hitTime++;
recordRunTime();
run();
break;
case 1 :
//暂停计时
hitTime++;
delete onEnterFrame;
break;
case 2 :
//恢复计时
hitTime++;
recordRunTime();
run();
break;
case 3 :
//停止计时
init();
delete onEnterFrame;
break;
}
};
function recordRunTime() {
beginRunTime = getTimer();
}
function run() {
onEnterFrame = function () {
trace(hitTime);
if (hitTime == 1) {
var totalHm = totalRunTime=getTimer()-beginRunTime;
} else if (hitTime == 3) {
var totalHm = getTimer()+totalRunTime-beginRunTime;
}
var totalM = int(totalHm/1000);
var hm = totalHm%1000;
var m = totalM%60;
var f = int(totalM/60);
timeText.text = f+":"+m+":"+hm;
};
}
var timeText:TextField = this.createTextField("time", 0, 0, 0, 100, 20);
function init() {
hitTime = 0;
beginRunTime = 0;
totalRunTime = 0;
timeText.text = "00:00:00";
}
init();
onMouseDown = function () {
switch (hitTime) {
case 0 :
//开始计时
hitTime++;
recordRunTime();
run();
break;
case 1 :
//暂停计时
hitTime++;
delete onEnterFrame;
break;
case 2 :
//恢复计时
hitTime++;
recordRunTime();
run();
break;
case 3 :
//停止计时
init();
delete onEnterFrame;
break;
}
};
function recordRunTime() {
beginRunTime = getTimer();
}
function run() {
onEnterFrame = function () {
trace(hitTime);
if (hitTime == 1) {
var totalHm = totalRunTime=getTimer()-beginRunTime;
} else if (hitTime == 3) {
var totalHm = getTimer()+totalRunTime-beginRunTime;
}
var totalM = int(totalHm/1000);
var hm = totalHm%1000;
var m = totalM%60;
var f = int(totalM/60);
timeText.text = f+":"+m+":"+hm;
};
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询