Flash movie speeding up on each play

Hi,

I have a flash game that plays fine the first time but when i play it the 2nd time round, it speeds up. (code of the timer frame below)

Any thoughts on how i can resolve this?

Any help on this would be greatly appreciated! it's a bit urgent!

thanks

Rachel :)


stop();
btnhand._visible = false;
goahead._visible = false;
hand._visible = false;

_root.myTimer = setInterval(wait, 1000);
var shots = 0;
var hits = 0;

var myTimer = 9;
var myLevel = 1;
function wait() {
    if (myTimer > 0) {
            myTimer--;
      }
      if (myTimer == 0 and myLevel == 1){
            myLevel = 2;
            myTimer = 6;
            duck1.gotoAndStop('alive');
            duck2.gotoAndStop('alive');
            duck3.gotoAndStop('alive');
            duck4.gotoAndStop('alive');
            duck5.gotoAndStop('alive');
      }
      else if (myTimer == 0 and myLevel == 2){
            myTimer = 4;
            myLevel = 3;
            duck1.gotoAndStop('alive');
            duck2.gotoAndStop('alive');
            duck3.gotoAndStop('alive');
            duck4.gotoAndStop('alive');
            duck5.gotoAndStop('alive');
      }
      else if (myTimer == 0 and myLevel == 3){
            duck1.gotoAndStop('alive');
            duck2.gotoAndStop('alive');
            duck3.gotoAndStop('alive');
            duck4.gotoAndStop('alive');
            duck5.gotoAndStop('alive');
            goahead._visible = true;
            mouse_mc._visible = false;
            hand._visible = true;
            hand._x=_root._xmouse;  
            hand._y=_root._ymouse;
            goahead.onPress = function(){
                  if (_root.shots  == _root.hits){
                        gotoAndStop('StarWinner');
                  }
                  else
                  {
                        gotoAndStop('prizes');
                  }
            }
            
      }
}
rachelgallenAsked:
Who is Participating?
 
CyanBlueCommented:
Put a trace inside the wait function and see if you see the duplicates which should tell you the interval is cleared or not.

CyanBlue
0
 
CyanBlueCommented:
Do clearInterval before you do setInterval. That probably will fix the problem.

CyanBlue
_root.myTimer = setInterval(wait, 1000);

...should be...

if (_root.myTimer) clearInterval(_root.myTimer);
_root.myTimer = setInterval(wait, 1000);

Open in new window

0
 
rachelgallenAuthor Commented:
tried it. didn't work. i do clear the interval at the play again scene on button press before returning to this frame.
0
 
rachelgallenAuthor Commented:
I put the trace in. it helped.
i fixed it by renaming my Timer and Interval variables. think it was getting mixed up.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.