PDA

View Full Version : Probs on clearInterval


Langy
04-02-2006, 08:05 PM
OK, I got the previous setInterval working fine.
I've now added a couple more in and got some more problems.

The main problem here is that when enlargeGal is called the clearInterval does not stop enlargeGal. It definately calls the clearInterval for enlargeGal.

One possible thought is that it is the loop (lp) that may cause the problems.

Any suggestions most welcome.

Langy


var enlargeGal:Number;
var reduceGal:Number;

if (GalLoaded==2) {
curPic = 1;
for (lp=1; lp<GalSize+1; lp++) {
if (lp!=curPic)_root["Gal"+lp+"_mc"]._alpha=30;
}

xJump = (250-galx[curPic-1])/20;
yJump = (270-galy[curPic-1])/20;
scaleStep = 75/20;
_root["Gal"+curPic+"_mc"].swapDepths(_root["Gal"+curPic+"_mc"].getDepth()+50);
enlargeGal = setInterval(scaleGallery,800, curPic, xJump, yJump, scaleStep);

}
if (GalLoaded==3) {
clearInterval(enlargeGal);
xJump = (galx[curPic-1]-250)/20;
yJump = (galy[curPic-1]-270)/20;
scaleStep = -75/20;
reduceGal = setInterval(scaleGallery,800, curPic, xJump, yJump, scaleStep);
_root["Gal"+curPic+"_mc"].swapDepths(_root["Gal"+curPic+"_mc"].getDepth()-50);
}



function scaleGallery(curPic, xJump, yJump, scaleStep) {
//trace (curPic + " - " + _root["Gal"+curPic+"_mc"]._yscale + " - " + xJump);
trace (reduceGal + " " + scaleStep);
if (_root["Gal"+curPic+"_mc"]._yscale<100 && GalLoaded==2 || _root["Gal"+curPic+"_mc"]._yscale>25 && GalLoaded==3) {
//trace (_root["Gal"+curPic+"_mc"]._x);
_root["Gal"+curPic+"_mc"]._x+=xJump;
_root["Gal"+curPic+"_mc"]._y+=yJump;
_root["Gal"+curPic+"_mc"]._xscale+=scaleStep;
_root["Gal"+curPic+"_mc"]._yscale+=scaleStep;
} else {
if (GalLoaded==2) {
clearInterval(enlargeGal);
GalLoaded=3;
} else if(GalLoaded==3) {
clearInterval(reduceGal);
GalLoaded=4;
}
}
}

lovefist233
04-06-2006, 07:49 PM
when you set an interval do it this way

_global.intervalName = setInterval(function, 99);
and to clear
clearInterval(_global.intervalName);

there is no way im going through that code to check for other errors but this is the main one, none of my intervals ever clear unless i make them global