这是简单的代码,但我无法解决.. 我点击 a.button,所以计时器运行,但如果我点击 b.button,计时器仍在运行。如何停止这个计时器?谢谢(对不起我的英语不好)
a.addEventListener(MouseEvent.CLICK, starts);
function starts(e:MouseEvent)
{
time(0);
}
b.addEventListener(MouseEvent.CLICK, stops);
function stops(e:MouseEvent)
{
time(1);
}
function time(cc)
{
var timer:Timer = new Timer(1000,100);
timer.addEventListener(TimerEvent.TIMER, tmer);
timer.start();
function tmer(e:TimerEvent):void
{
trace("start");
}
if(cc == 1)
{
trace("stop");
timer.stop();
timer.removeEventListener(TimerEvent.TIMER, tmer);
}
cc=0;
}