Im really beginning to lose it… All i wanted to do is make a stopwatch with a couple more functions.
At first everything worked. Later i changed some code (nothing to do with the setInterval function) and suddenly it doesnt work anymore! All it does is execute a function once and then stops.
Here is my code:
var sekunde:Number = 0; //seconds
var minute:Number = 0; //minutes
var intervalID:Number;
var stoparicaTece:Boolean = false; //is the stopwatch running
osveziStoparico();
function povecajSekunde(){ //increases the seconds
sekunde++;
if(sekunde>=60){
minute++;
sekunde = 0;
if(minute >= 60){
minute = 0;
}
}//1 minute
osveziStoparico();
}
function sproziStoparico(){ //initiates the stopwatch
if(!stoparicaTece){ //ce stoparica se ni bila pognana
intervalID = setInterval(povecajSekunde(), 1000);
stoparicaTece = true;
}
}
function ustaviStoparico(){ //stops the setInterval function
clearInterval(intervalID);
stoparicaTece=false;
}
function resetirajStoparico(){ //resets the stopwatch
sekunde = 0;
minute = 0;
osveziStoparico();
}
function osveziStoparico(){ //displays current seconds&minutes
stoparica.text = minute+":"+sekunde;
}
Thanks for your help because right now i want to hurl my computer through the window!
edit: i already tried restoring it to original state but it didnt work