• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1045
  • Last Modified:

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');
                  }
            }
            
      }
}
0
rachelgallen
Asked:
rachelgallen
  • 2
  • 2
1 Solution
 
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
 
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
 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now