I’ve got a simple timer set up… thanks to the guys at this forum. heres the code for the frame:
stop();
timer1=timer2=timer3=timer4="00";
var IntervalID;
function startTimer()
{
this.onEnterFrame=function()
{
timer1=getTimer();
timer1=timer1%100;
}
IntervalID=setInterval(timer,1000);
}
function timer()
{
timer2++;
if(timer2>59)
{
timer2="00";
timer3++;
}
if(timer3>59)
{
timer3=0;
timer4++;
}
timer2=attachZero(timer2);
timer3=attachZero(timer3);
timer4=attachZero(timer4);
}
function stopTimer()
{
clearInterval(IntervalID);
delete this.onEnterFrame;
}
function attachZero(time)
{
if(time>0 && time <10)
{
time="0"+parseInt(time);
return time;
}
else
return time;
}
function restart()
{
stopTimer();
timer1=timer2=timer3=timer4="00";
startTimer();
}
this is the code for the start button:
on(release)
{
startTimer();
}
and this is the code to stop the timer.
on(release)
{
stopTimer();
}
and it works great. however, i have inserted some music via actionscript. here is that code:
var lol:Sound = new Sound();
lol.attachSound("omg");
lol.start(0, 10);
heres my problem: when i start the timer with the start button, it stops the music… why is that, and how can i prevent it?