-
Game Timer Problems
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.
by the way I want my timer to go from 0 to 90.
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?
-
FK'n_dog
remove the onEnterFrame = function(stoppo){ .. }
this causes the code within the function to be
repeated at the FPS setting of your movie.
simply have -
clearInterval(myTimer);
myTimer = setInterval(wait, 1000);
and on frame#1 -
stop();
clearInterval(myTimer);
function wait() {
mySeconds++;
if (mySeconds == 90) {
gotoAndStop(70);
}
}
myTimer = setInterval(wait, 1000);
-
thanks a_modified_dog
Hi a_modified_dog
and thanks for your help!
I know the description of my game was a little short, so I wrote this code instead:
The code on frame 1 is untouched
and the code on the frames where I want the movie to stop the timer is like this:
clearInterval(myTimer);
Thanks again for your help I really appreciated it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|