quiz game timer

timer to game in flash 8

Page 1 of 1

3 Replies - 7553 Views - Last Post: 17 March 2008 - 02:00 PM

#1 copenhagen  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 90
  • Joined: 16-March 08

quiz game timer

Post icon  Posted 16 March 2008 - 11:04 PM

Hi

I am doing this game in flash 8 proffesionel, but my timer creates a lot of problems. I have been looking everywhere for help, but without any luck.

First I placed a dynamic textfield at frame 1 on the main timeline stage called: mySeconds in the var field.
and placed the value 0 in the textfield on the stage.

Then I wrote this code by opening the actionscript panel at frame 1 on the main timeline:

stop();
function wait() {
mySeconds++;
if (mySeconds == 90) {
gotoAndStop(70);
}
}
myTimer = setInterval(wait, 1000);

Then I place a keyframe on frame 10, 20, 30, 40 50, 60 and 70 where the player is taken to each of these keyframes during the game.

I want the timer to stop on frame 40, 50, 60 and 70 so I put this code on frame 40, 50, 60 and 70:

onEnterFrame = function(stoppo) {
clearInterval(myTimer);
myTimer = setInterval(wait, 1000);
}

the above code stops the timer, so until now the timer works great, BUT when I then write: gotoAndStop(1) after the code on frame 40, 50, 60 and 70
so the movie begin playing frame 1 again, then my timer goes crazy.

Does anybody know how to make a timer who will work in my kind of game?

This post has been edited by copenhagen: 17 March 2008 - 09:30 AM


Is This A Good Question/Topic? 0
  • +

Replies To: quiz game timer

#2 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: quiz game timer

Posted 17 March 2008 - 12:34 PM

I'm not sure if I fully understand what you want, but to stop your timer at a certain point you don't need onEnterFrame. What onEnterFrame does is repeats the code within it each time a frame within the calling scope is hit, and continues to do so until you set it to null, so you constantly stop and start your timer even when you've gone back to frame 1.

To simply stop your timer at any point, all you need is:

clearInterval(myTimer);



Now your timer won't start again until you go back to frame 1 and restart it.

Hope that helps :)
Was This Post Helpful? 0
  • +
  • -

#3 copenhagen  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 90
  • Joined: 16-March 08

Re: quiz game timer

Posted 17 March 2008 - 01:43 PM

Hi thehat

Thanks to your code my timer works like I wanted it to!

I really appreciated your help, you saved my day!
Was This Post Helpful? 0
  • +
  • -

#4 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: quiz game timer

Posted 17 March 2008 - 02:00 PM

You're welcome :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1