PDA

View Full Version : Set Interval script issue



sprntrl
July 7th, 2002, 07:40 PM
Can someone tell me why the following script causes my mc to duplicate every second but when it does it gets rid of/overwrites the instance before it. I'm trying to make an escalator and the stair gets half way up when the next step starts and deletes the one prior to it.

setInterval(stepoff, 1000);
function stepoff() {
counter = 1;
duplicateMovieClip("step", "step"+counter, counter);
counter++;
}

sbeener
July 7th, 2002, 07:51 PM
because you reset counter to 1 each time.

Iammontoya
July 7th, 2002, 09:24 PM
dont really need a/s for that.. here is a very very simple version. It can be cleaned up to look just fine.

sprntrl
July 7th, 2002, 11:37 PM
Inigo, I clicked on the link but zero files came up in winzip. Can you email the fla. sprntrl@yahoo.com. As far as the counter should I initialize it to 1 prior to the function or jus get rid of the =1.

pom
July 8th, 2002, 11:11 AM
counter = 1 ;

function stepoff() {
duplicateMovieClip("step", "step"+counter, counter);
counter++;
}

setInterval(stepoff, 1000);I don't think there will be a problem, but if there is, it might come from the fact that you define counter in this frame. I don't know.

And concerning the reason why it was doing this, it's just that you duplicated the step in the layer 1, or the level 1, and when you do so, Flash removes what previously was on that layer. Hence the increment in the counter.

pom
:asian:

sbeener
July 8th, 2002, 04:45 PM
or:


function stepoff() {
duplicateMovieClip("step", "step"+(counter++), counter);
}


counter will be initialized as 1 in the first iteration. that means you won't have a "step0" movie in level 0 (it will start with "step1" in level 1).