Delay Movie

I’m trying to use a setInterval to delay my movie …

It’s not waiting the correct duration that is noted. Here’s the code:

delay = 6000;
// milliseconds
function playMovie() {
gotoAndPlay(16);
clearInterval(pauseInt);
}
stop();
pauseInt = setInterval(playMovie, delay);

It works fine, but when I change 6000 to something like 12000, it doesn’t wait that long.

Another thing to remember is that I have about 6 of these in different frames on the timeline. Is the ‘clearInterval’ in the right place?

I’m lost…

http://www.actionscript.org/actionscripts_library/main/search.cgi?query=pause

There a some pause functions there that are great.

Thanks for the link, but it’s not working.

I’m using this one:

In your main “action” timeline, frame 1 put the following code:
////////////////// Pause Function /////////////////////
this.createEmptyMovieClip(“timer”,50);
timer.onEnterFrame = function()
{
if (this.startTime>0)
{
var diff = getTimer()-this.startTime;
if (diff>this.timerLength)
{
this.target.play();
this.startTime = 0;
}
}
};
function pauseFor(theTime)
{
stop();
timer.timerLength = theTime;
timer.startTime = getTimer();
timer.target = this;
}
///////////////////////////////////////////////////
Then on the frame you want to pause, add: pauseFor(3000) //this would pause for 3 seconds.

What exactly do I need to put on the pause frame, and can I use this multiple times in the same timeline?

The instructions for it are right there…

First Line

In your main “action” timeline, frame 1 put the following code:

Very Last Line

Then on the frame you want to pause, add: pauseFor(3000) //this would pause for 3 seconds.

Hope that helps :slight_smile:

I would assume you could just put the pauseFor(3000) on any frame you want to pause, not just one.

Right… that’s what I did. I put the code in the first frame, and then I put the pause in the other frames.

pauseFor(3000)

That code looks like weird syntax, no “;” or anything.

It’s just not working for me …

Try copying and pasting this on Frame 1(It worked without syntax errors for me, I am supposing the smileys got in your way, so I am posting it again without the smileys)…

 ////////////////// Pause Function /////////////////////
this.createEmptyMovieClip("timer", 50);
timer.onEnterFrame = function() {
	if (this.startTime>0) {
		var diff = getTimer()-this.startTime;
		if (diff>this.timerLength) {
			this.target.play();
			this.startTime = 0;
		}
	}
};
function pauseFor(theTime) {
	stop();
	timer.timerLength = theTime;
	timer.startTime = getTimer();
	timer.target = this;
}
///////////////////////////////////////////////////

And put this on the frame you want to pause…

pauseFor(3000);

Alright… I’m just retarded … lol

I was totally in the wrong scene… doh!

It’s working fine now…

Thanks for the tip.

No problem, I actually like this script so I think I will save it in a file on my comp for later reference…LOL.

One more question lostinbeta…

I’d like to apply a script on some VCR buttons to stop the movie completely at any time. I need that button to clear out the ‘pause’… so how would I clear the interval out. I’ve tried numbeous methods, but nothing is working.

I have never done this before, so I am taking a shot in the dark on what you are doing…

To clear the current interval out you need to use the clearInterval(); command.

Right… that and it work on all the ‘inbetween’ frames, but it’s not clearing it on the frames with the actual ‘pause’.

I bet it’s because it’s pausing and not hearing the button command to clear the interval.

What do you think would help this?

Ok, I just realized that the pause script uses getTimer to setInterval, so clearing the interval won’t help unless you have another script that uses it.

[edit] erased all[/edit]

oh, I´m must be drunk…

sorry:*(

Soooo… recommendations on how to clear it, being that it is a getTimer?

You can’t reset a getTimer(), you have to subtract it from itself.

This is already done in the pause script, so it should help give you an idea how to do it, the line that does it is…

var diff = getTimer()-this.startTime;

As you see, timer.startTime = getTimer() (says it all the way at the bottom)

That is like saying getTimer() -getTimer(), but since you can’t do that, you have to subtract the variable.

Confusing I know…lol.

lostinbeta…

Sorry to bug you again man, but this thing is driving me crazy. Here’s my code:

on(press) {
var diff = getTimer()-this.startTime;
_level1.stop();
}

It’s still the same problem. I can get it to stop when it’s in a tween, but won’t stop when it’s on a frame with the ‘pause’ function attached.

I’m also wondering… if you clear out the ‘timer’, how will it be re-instated? I also have a play button… how am I going to let the function know to getTimer again?

Thanks ahead of time for all the help.

Well if the movie is paused, why do you want to stop it?

Don’t need to reinstate getTimer(), it is always adding up, that is why you must subtract it from itself, because it keeps going higher and higher the longer your movie is played.

I am not sure how to fix the problem, you are tackling something I have never tackled, and from what it sounds like, it is probably out of my league :-\

I haven’t been flashing for too long.

Well… the movie pauses… and if the user needs more time to look at that section, I have a stop button.

Know what I mean?

May I ask why you pause it automatically? For some odd reason, this might help me, not sure…lol.