flash Timer类使用

作者:袖梨 2022-07-02

代码如下

var i:Number=0;
var myTimer:Timer = new Timer(100);
showText(i)
function StartTimer(Event:MouseEvent) {
 myTimer.addEventListener("timer", Tracetimer);
 myTimer.start();
}
function Tracetimer(event:TimerEvent):void {
 i++;
 showText(i)
 //trace("timerHandler: " + event);
}
function showText(i:Number){
 my_txt.text="这是第"+i+"次循环";
}
function StopTimer(Event:MouseEvent) {
 myTimer.stop();
}
function ResTimer(Event:MouseEvent) {
 myTimer.reset();
 i=0
 showText(i)
}
btn_play.addEventListener(MouseEvent.CLICK,StartTimer);
btn_stop.addEventListener(MouseEvent.CLICK,StopTimer);
btn_res.addEventListener(MouseEvent.CLICK,ResTimer);

相关文章

精彩推荐