PDA

View Full Version : setInterval bug???



oceans11
January 7th, 2004, 12:43 PM
MC Timeline --> its last frame --> /*script*/ stop(); function nextAd(){} ID=setInterval(nextAd,5000);

EXPECTED: animating MC should repeat every after 5 seconds, once it has reached its last frame.

OUTPUT: first 2-4 intervals run, it works right,then after next iteration,
EITHER MC does gotoandstop to its frame1 then PAUSES for 5sec(the interval), which should have been MC PAUSE FIRST then goto frame1..
OR the animation runs with like 500 milliseconds interval, that fast.

Why!?


stop();
Amsg = new Array("AVAILABLE IN LIQUID CN-9", "AND DRY CALCIUM NITRATE.");
function nextAd() {
if (photo._currentframe == photo._totalframes)
{ photo.gotoAndStop(1); }
else photo.gotoAndStop(photo._currentframe+1);
if (j == Amsg.length-1) {
msg = Amsg[0];
j = 0;
}
else msg = Amsg[j += 1];
gotoAndPlay(1);
}

adIntv = setInterval(nextAd, 5000);

senocular
January 7th, 2004, 01:01 PM
gotoAndPlay(1) at the end there. That goes back to frame 1. plays it, then comes back to the frame that code's on and makes a new interval giving you mulitple intervals screwing you up. So all that has to be defined somewhere else.

oceans11
January 7th, 2004, 01:08 PM
SO you think i really cannot implement that through setInterval() .. Coz this MC goes in the same frame where a preloader is in (which goes back and forth to this frame) :(

kill.robot.kill
January 7th, 2004, 03:16 PM
couldn't you just clear the old interval before the code?
Just set up a clearInterval() before all your code, I haven't tested this, just a thought.

oceans11
January 7th, 2004, 08:46 PM
Bows down to kill.robot.kill Woooooooooo!!!!!!
I wanna extend my thanks to senocular as well. you don't know how much this means to me :)

tommythewolfboy
March 24th, 2004, 04:04 PM
Can you share the final code for this? I'm having the same headache! Did you put the clearInterval(adIntv) before ALL of the code, or just (immediately) before setInterval? thanks