setInterval Frustrations

I can’t find the reason why this doesn’t work:

function loadDelay() {
_root.Menu.loadMovie(“02.swf”, “_root.Menu”);
}
blah = setInterval(loadDelay, 6000);
clearInterval(blah);

I have a button, what it should do is wait 6 seconds, then load the movie ‘02.swf’ into the empty MC ‘Menu’.

Now I’ve tried this as well:

setInterval(_root.Menu.loadMovie, 6000, “02.swf”);

This one loads the movie appropriately, but not into the empty MC. I cannot figure out how to tell it to load into ‘_root.Menu’ and not just the root.

I think I’m just getting the syntax wrong or something, any help would be appreciated. Thank you.

try this:

function loadDelay() {
_root.Menu.loadMovie("02.swf", "_root.Menu");
clearInterval(blah);
}
blah = setInterval("loadDelay", 6000);

Although the code posted by lorcas code should work, the correct sintax for the second method you tried, Rojo, is:
[AS]setInterval(_root.Menu, “loadMovie”, 6000, “02.swf”);[/AS]
Be careful though, the movie will reload every 6 seconds since the interval is never cleared.

Thank you both. I’m still having a bit of trouble though, if you don’t mind helping me further…

Lorcas, I put in your code and it did not work unfortunately. It seems like everything is all right there in the right places, but the movie won’t load.

Kode, that works great, but yes it keeps reloading. I tried to do the obvious:

blah = setInterval(_root.Menu, “loadMovie”, 6000, “02.swf”);
clearInterval(blah);

It didn’t work, how can I tell this to clearInterval? Or does the first code format only allow for clearInterval?

So close… ugh

Oops! I didn’t see those errors in the code!
[AS]function loadDelay() {
_root.Menu.loadMovie(“02.swf”);
clearInterval(blah);
}
blah = setInterval(loadDelay, 6000);[/AS]
…Sorry, I should have read carefully. :frowning:

****… it still doesn’t work. I think there is a problem somewhere else, it is the only explanation.

Thanks for the help again.

Uhmm… make sure that you’ve assigned the instance name to the MovieClip and the path is correct. :-\

I just don’t get it. This code works perfect, except for the fact that it keeps repeating:

setInterval(_root.Menu, “loadMovie”, 6000, “02.swf”);

So if that works it means the names and paths are correct… :-\ Should I just upload the file?

Originally posted by Rojo
So if that works it means the names and paths are correct…

…So true. :stuck_out_tongue:

And yes, upload the FLA. :slight_smile:

http://www.timdeneau.com/kirupa.zip

I renamed the empty MC from ‘Menu’ to ‘Character’ because I forgot something else was named ‘Menu’ too! That wasn’t the problem though, but I renamed it anyway to avoid further headaches.

Well, I changed the named function to an anonymous function and it worked right away. :-
[AS]loadDelay = function () {
_root.Character.loadMovie(“00.swf”);
clearInterval(blah);
};
blah = setInterval(loadDelay, 6000);[/AS]
I don’t know what’s the problem with the named function, though. :-\

Yeah, hmm, I don’t understand how that works and the other doesn’t. But hey at least it works now.

Thank you for all your help, kode. :beam:

No problem, I guess… I don’t like these moments when the problem is solved but I have no idea why. :-\