can I clear a interval in a function from another function?
Here is my current code:
right now I have it like this but this isn’t doing the trick.
startInterval = function() {
var rotateInterval = setInterval(rotateThumbs, 3000);
clearInterval(restartInterval);
}
var world:Array = new Array();
var rotate:Number = 0;
var fl:Number = 2000;
var clip;
var thumbsAmt:Number = 8;
var thumbCount:Number = 0;
var step = (2*Math.PI)/thumbsAmt;
// ====================================================================================
// LOAD THUMBS INTO PANELS / CREATE BUTTONS
// ====================================================================================
loadThumbs = function () {
var th = 'th'+thumbCount;
var panel = worldMc.attachMovie("img"+thumbCount+"_mc", th, thumbCount);
panel.radius = 236;
panel.angle = step*thumbCount;
panel.x = Math.cos(panel.angle)*w.radius;
panel.y = 300;
panel.z = Math.sin(panel.angle)*w.radius;
_root.worldMc.th0.loader_mc.loadMovie("horizons.swf");
_root.worldMc.th1.loader_mc.loadMovie("colorweb.swf");
_root.worldMc.th2.loader_mc.loadMovie("accessenergy.swf");
_root.worldMc.th3.loader_mc.loadMovie("musicianshotline.swf");
_root.worldMc.th4.loader_mc.loadMovie("aspect.swf");
_root.worldMc.th5.loader_mc.loadMovie("sportsauth.swf");
_root.worldMc.th6.loader_mc.loadMovie("iowacity.swf");
_root.worldMc.th7.loader_mc.loadMovie("freedomfestival.swf");
var numberOfButtons:Number = 8;
var currentButton = null;
for (i=0; i<=numberOfButtons; i++) {
_root.worldMc["th"+i].onRelease = function() {
currentButton.loader_mc.gotoAndStop(1);
currentButton.background_mc._visible = true;
currentButton = this;
rotate = this.angle;
clip = this;
this.loader_mc.gotoAndPlay(1);
this.background_mc._visible = false;
clearInterval(rotateInterval);
var restartInterval = setInterval(startInterval, 10000)
if(this.loader_mc._currentframe = 10) {
rotate = currentButton.angle;
clip = currentButton;
currentButton.background_mc._visible = true;
}
};
}
world.push(panel);
thumbCount++;
if (thumbCount == thumbsAmt) {
clearInterval(thumbsInterval);
clip = worldMc.th0;
worldMc.onEnterFrame = function() {
for (var i = 0; i<world.length; i++) {
var w = world*;
rotate += (clip._x)/4000;
var angle = w.angle-rotate;
var x = Math.cos(angle)*w.radius;
var y = w.y;
var z = Math.sin(angle)*w.radius;
var scale = fl/(fl+z);
w._x = x*scale;
w._y = y*scale-320;
w._xscale = w._yscale=100*scale-15;
w.swapDepths(Math.ceil(-z));
}
};
}
};
// ====================================================================================
// ====================================================================================
// HANDLE AUTOMATIC ROTATION
// ====================================================================================
var counter:Number = 0;
rotateThumbs = function () {
counter++;
if (counter>7) {
counter = 0;
} else {
}
var fieldName:String = "th"+counter
rotate = _root.worldMc[fieldName].angle;
clip = _root.worldMc[fieldName];
for(a=0; a<8; a++){
_root.worldMc["th"+a].background_mc._visible = true;
_root.worldMc["th"+a].loader_mc.gotoAndStop(1);
}
};
// ====================================================================================
var rotateInterval = setInterval(rotateThumbs, 3000);
startInterval = function() {
var rotateInterval = setInterval(rotateThumbs, 3000);
clearInterval(restartInterval);
}
var thumbsInterval = setInterval(loadThumbs, 0);