用flash as3.0制作一个10分钟倒计时(精确到毫秒)!求源代码~~

2024年11月17日 19:48
有2个网友回答
网友(1):

这种样子的,行吗?

网友(2):

package{
import flash.display .MovieClip;
import flash.events .*;
import flash.utils.Timer ;
import flash.text.TextField;

public class Dao extends MovieClip{
var txt:TextField;
var i:Number=1;
var myTimer:Timer;
var zong:Number;
var m:int;
var s:int;
var hs:int;
//var ts:int;
//var tm:int;
//var tms:int;

public function Dao(){
txt=new TextField();
txt.x=150;
txt.y=200;
txt.width=300;
addChild(txt);
myTimer= new Timer(10);

btn1.addEventListener(MouseEvent.CLICK,mc);
btn2.addEventListener(MouseEvent.CLICK,mp);
}

public function mc(Event:MouseEvent) {
myTimer.addEventListener(TimerEvent.TIMER, showText);

myTimer.start();
}

public function showText(event:TimerEvent) :void{
zong=10*60*100-i;
m=int(zong/100/60);
s=int(zong/100%60);
hs=int(zong%100);

//m=int(zong/100/60);
//s=int(zong/100/10);
//hs=int(zong/10/60);
txt.text="倒计开始:"+m+"分"+s+"秒"+hs+"毫秒";
i++;

}

public function mp(Event:MouseEvent) {
myTimer.stop();
}
}

}