clearInterval (help needed)

I got this to work. But I also want to
clear the interval on this MC.

function wait() {
    _root.createEmptyMovieClip("holder",1);
    holder._y = 120;
    holder.loadMovie("myClip.swf");
}
myInterval = setInterval (wait, 2000);

Can anyone help me with this?

Thanks

regards

[AS]function wait() {
_root.createEmptyMovieClip(“holder”,1);
holder._y = 120;
holder.loadMovie(“myClip.swf”);
clearInterval(myInterval);
}[/AS]

clearInterval(intervalID);

myInterval in your case would be your intervalID.

Thanks a lot lost,

I tried this also, but thought it had to be called after the variable.

myInterval = setInterval (wait, 2000);
clearInterval(myInterval);

I don’t realy understand why it’s put there.
It works though!

Could you explain a little, if time?

regards

setInterval runs a function after the specified amount of time.

If you clear the interval before that time is up, no function will be run because the setInterval will be canceled out before it can run it.

So what you can do is run the clearInterval within the function you are calling, so that way the setInterval gets cleared after your function has already been called :slight_smile:

though wait is defined before the interval is called, its the interval that actually runs wait, and is THEN that myInterval can be cleared and stopped… after its been run (which would happen after its been defined)

[edit] beaten to it :slight_smile: [/edit]

man sen, you said what i said in so much less words, and much more clearer.

you bastard :stuck_out_tongue:

you think its clearer? After I posted it I read it (I only read what I put After I post heh) and I confused myself :stuck_out_tongue: lol

perhaps i’m just used to reading your posts :stuck_out_tongue:

Thanks both of you,

I still have to configure my brain a little more
to see the logic in this kind of issues.
But it does sound logic.

good weekend,

regards