flash Timer类使用
代码如下
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);
补充:flash教程,As3.0