clearInterval

How exactly would I clear this interval with my button?

//===============================
//PAUSE FUNCTION
//===============================
	function pause(t, v)
	{
		t.interval = setInterval(unPause, v, t);
		t.stop();
	}

	function unPause(t)
	{
		trace("clear & play");
		clearInterval(t.interval);
		t.play();
	}

//===============================
// INITIATE FUNCTION
//===============================
	pause(this,3000);

Would I clear the “t.interval” or do I clear the function “(pause)”?

i don’t know if you can assign it the name t.interval…thats like creating a variable called my.Sound or something, probably isnt very good. Try the following:

[AS]
//===============================
//PAUSE FUNCTION
//===============================
function pause(t, v)
{
tInterval = setInterval(unPause, v, t);
t.stop();
}

function unPause(t)
{
trace(“clear & play”);
clearInterval(tInterval);
t.play();
}

//===============================
// INITIATE FUNCTION
//===============================
pause(this,3000);

I see… thanks for the tip.

But, the question is… If I want to clear this interval… how would I do it. Would it be:

clearInterval(tinterval);

or would it be

clearInterval(pause);

or would it be something entirely different.

Thanks for the help!

tInterval

So… will that globally clear that interval? Cause that is basically what I need to do. I need to clear all the intervals when I hit my “back” button.

you will need to clear each one by itself then. I dunno if you can create a global Interval and then clear that, ask someone like lost, kode, or sen.

Well… nevermind the _global clear… What if I want to clear the interval from some other loaded movie, would I do it like this:

 _root.somemovie.anothermovie.clearInterval(pause);

I just need to shut the function totally off. I’ve even tried unloading the movie, but the output window shows that it’s still running the interval function.

How can I turn it off?

you dont clear the function name, you clear whatever you assigned the value of setInterval to. So it would be
[AS]
_root.someMovie.anotherMovie.clearInterval(tInterval);
[/AS]

Sorry, but it’s not working for me. I’ve got a button on my _root that’s calling down through 2 sub-movies, but it’s not picking it up.

_root.movieLoader.subMovieLoader.clearInterval(stall);

Shouldn’t it talk to what ever movies are loaded into the “movieLoader” and “subMovieLoader”?

try tracing to make sure your path is correct

Not exactly sure how to do that with the clearInterval. I have a trace set up in my setInterval function, and it displays everytime the function runs. Is that what you mean?

Otherwise, I’m not sure how to run the trace for the “clearInterval”.

Would it be something like this?

if(_root.movieLoader.subMovieLoader.clearInterval(stall);{
trace(it got cleared);}

yeah (but you are missing a parenthesis there :wink: ) I dunno if that will work because I don’t know whether clearInterval returns a boolean value. You might just want to check the path.

[AS]
trace(_root.movieLoader.subMovieLoader);
[/AS]

Wow… I learned something new. I never knew you good check paths like that.

Well… the output window is showing “undefined”, so I guess it’s not picking up the path… which sucks.

I mean… that’s a direct path… it should work, what else can we do?

If there is a movie called “orange” that is loaded into a blank mc called “movieLoader”… You should just be able to talk to the “orange” movie by calling “movieLoader”, right?

yes. if you load a movie clip into another, it takes on the attributes of the first and can be referenced using the instance name of the first.

This totally sucks then… cause the path should be right. I can’t think of anything else right now. I think I need to step away and go get a drink real fast… I’ll be back to stare at this thing some more.

I appreciate all the help…

welcome

Hi,

try trace(targetPath(_root.movieLoader.subMovieLoader));

that should give you the same path that you put in if it’s correct. If not then it will return undefined I think.

The other thing to try is in the onClipEvent(load) of the subMovieLoader put… trace(targetPath(this)); and that will give you the path to that movie clip.

Hope this helps.

Liz

or you can just

trace(this);

same thing.

Wow… that’s another kewl tip also… thanks!

But… still no dice. Not working.k

The trace returned “_level0.movieLoader.subMovieLoader”, so I inserted on my _root button like this:

_level0.movieLoader.subMovieLoader.clearInterval(stall);

But… it’s still not clearing it out. This is lame… :frowning:

dunno man. sorry. is your interval named stall? and did you set it right? not sure