Basically, I have a presentation movie with a few complexities to it.
The movie Plays, then waits an interval of time, then resumes (works alright)
The movie needs to have a pause button (that will pause the action) and a play button that will resume the action.
My problem: Once I pause and then hit play the play button ignores the “countdown” of setInterval and just “skips” ahead to the next part.
I’m putting in a voice over and I really need that interval of time there or stuff will run into each other.
Can anyone help?
Here’s a sample of code:
On the first frame (but indicative of the rest):
stop();
/* Sound Stuff */
var mySound = new Sound(this);
mySound.attachSound("soundIntroduction");
mySound.start();
mySound01.onSoundComplete = function()
{
_root.nextFrame();
}
function wait() {
gotoAndPlay(2);
clearInterval(myTimer);
}
myTimer = setInterval(wait, 61000);
The play button there’s a clearInterval in here, but without it the play button will keep repeating everything. I guess this is the key, but I don’t know how to get around this:
that will obviously not please your computer if you have mre complex stuff going on at the same time… but its the only way i can think of… and it should b ok… try it an see… obviously, if its not imperitive you have it accurate to the millisecond you could increase the 1… lol
now. on the play button, we are not just calling your setInterval defined to run the function wait but we are also setting up a parallell setInterval to run at the same time. this will increase the variable i every time it is run (ie, every millisecond)… this means that we now have a running total of how many milliseconds have passed since it was originally called (consequently at the same time as your wait setInterval), hence we also have a running total of how many milliseconds of the wait setInterval have passed. If you set the every millisecond interval to trace i as well as increment it you will see what i mean.
now on our play button, we dont want it to start every time at 61000ms do we? we want 61000ms, minus however milliseconds of the setInterval has already witnessed… conveniantly this is stored in the variable i so we start the interval and tell it to run “every” 61000-i
eg. if we have paused at 6000ms, the i++ setInterval will have run 6000 times and i will therefore equate to 6000
if we now hit play, it will read it as setInterval(wait,61000-6000) which is obviously, equivalent to setInterval(wait,55000)
if it is not imperative that it is milisecond accurate, you may want the i++ setInterval to run say every 10ms… in this case, you will need to increment i by 10 each time (ie. i+=10 ) for the code to remain working ok…
i hope thats a little clearer… if im still rambling, post your fla and ill put it in your code for you ok?