Be a Supporter!

Stopping a Timer in AS2

  • 189 Views
  • 2 Replies
New Topic Respond to this Topic
ArcatraZ
ArcatraZ
  • Member since: Apr. 28, 2003
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Stopping a Timer in AS2 2009-05-12 06:57:16 Reply

Hey, I've got some code here for a simple timer. When the timer counts down to zero it goes on to a "gameover" screen.
That part is fine.

I also have a system where if you get enough points you go to the "WIN" screen. However in the WIN screen, the timer still counts down and can take you to the "gameover" screen.

How do i make the timer stop once I've got to the WIN screen? The different screens are on the main timeline but different frames ofc.

Thanks in advance.

this.onEnterFrame = function() {
timerVariable = timerVariable+1;
if (timerVariable == 25) {
timer -= 1;
timerVariable = 0;
}

if (timer<0) {
timer = 0;
this.gotoAndStop("gameover");

dragonjet
dragonjet
  • Member since: Dec. 2, 2005
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to Stopping a Timer in AS2 2009-05-12 07:25:43 Reply

this.onEnterFrame = function() {
timerVariable = timerVariable+1;
if (timerVariable == 25) {
timer -= 1;
timerVariable = 0;
}

if (timer<0) {
timer = 0;
this.gotoAndStop("gameover");

Please finish the code fragment, some closing braces are missing.
I'm guessing there are more codes before the close brace?

but to give you an idea,
when you go to the win screen, you can just

delete this.onEnterFrame;
Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to Stopping a Timer in AS2 2009-05-12 07:26:02 Reply

try this:

CurrentFrame = _currentframe
this.onEnterFrame = function() {
if(CurrentFrame==_currentframe){
timerVariable = timerVariable+1;
if (timerVariable == 25) {
timer -= 1;
timerVariable = 0;
}
}

AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature