Many years have been using onIntervel and there always is a problem with it. So we have put together this post to help and make your life easier.
Please, note that flash onIntervel is only available from flash 6 player and actionscript 1.
Here is a code i have put together…
//
function funToRun() {
trace(”var1:”+var1);
var1++;
//
if (var1 == 3) {
//
trace(”if cond true”);
clearInterval(intervalItem);
//
}
//
}
//
function stopIntervalFun() {
trace(”stop called!”);
clearInterval(intervalItem);
var1 = 0;
}
//
function startIntervalFun() {
trace(”start called!”);
var1 = 0;
clearInterval(intervalItem);
intervalItem = setInterval(funToRun, 500);
}
//
butt1.onPress = function () {
//
startIntervalFun();
//
}
butt2.onPress = function () {
//
stopIntervalFun();
//
}
//
FLA of onIntervel code
This i have noticed is best way of using the onIntervel method. Be sure to always clearIntervel before moving on. Otherwise there are always problems, where it does not stop and different odd behaviors take place.