Skip to main content
December 3, 2007
Answered

Reseting a function/movie

  • December 3, 2007
  • 6 replies
  • 262 views
Hi,

I'm creating a short movie using a script I found (not mine) but I'm not sure how to reset the script to stop multiple instances running.

I have three frames the first with a button to go to the next frame, the second with the fireworks script (below). After a pause the the third frame which offers the user to view the movie again.

Currently each time the movie is viewed another instance of the function is created (I think) resulting in more and more fireworks and a big slow down. I just want it to run from scratch each time, which is simple I guess but I not really a very regular flash user.

Thanks

Here is the script.
This topic has been closed for replies.
Correct answer Greg Dove
I took a look at your post earlier, but struggled to understand it.

this code is calling initRaketen() every 2.5 seconds.

I think that probably on your frame 3, you want to have this line:
clearInterval(iv);

but I must confess, I'm not entirely sure from your description.



var iv = setInterval(initRaketen, 2500);

6 replies

Inspiring
December 3, 2007
Great to hear!
Inspiring
December 3, 2007
Did you try this for frame 3:

clearInterval(iv);
December 3, 2007
Yes I've tried it and it does exactly what I was after.

Your help is much appreciated.
December 3, 2007
No problem I didn't mean to sound impatient, I was just trying figure out a different way to solve the problem.

Basically the script calls initRaketen which creates a firework effect every secs 2.5.

I need to be able to start and stop this effect on different frames: frame 1 - off, frame 2 - on, frame 3 off.

Currently that works, I have the script on frame 2 and the following on frame 3 to halt it:
MovieClip.prototype.setzeRaketen =0 (just a guess from me that seems to have worked)

However if I play the the movie again from frame 1 I get two sets of fireworks every 2.5 secs, as if the script were being run twice every 2.5 secs at the same time.

Thanks and I hope that is clearer.
Inspiring
December 3, 2007
BTW, this forum seems mostly active when the US is awake. There's a few of us in Europe/UK and other parts of the world, but I think the majority of activity comes from the US. So often it pays to wait a few hours at least for a response. I was holding off posting because I thought someone else might understand you issue better than I.
Greg DoveCorrect answer
Inspiring
December 3, 2007
I took a look at your post earlier, but struggled to understand it.

this code is calling initRaketen() every 2.5 seconds.

I think that probably on your frame 3, you want to have this line:
clearInterval(iv);

but I must confess, I'm not entirely sure from your description.



var iv = setInterval(initRaketen, 2500);
December 3, 2007
Ok I assumed this would be easy but I'm not really sure...

How about is it possible to reload the entire movie with a button click like you would click refresh on a web page?

Thanks again.