This is simple code but i cant solve..
i clik a.button, so the timer runs, but if i click b.button, timer is stil running. How to stop this timer?? Thanks
(sorry my bad english)
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;
}
try to this: