flash计时器

楠楠家庭教育 | 学以知道 , 教以成德!         

问题描述

flash计时器,麻烦给回复
精选答案
最佳答案

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

更多推荐
(c)2008-2025 广知网 All Rights Reserved 鄂ICP备2023002720号-19