0
votes

whenever i test my flash game in flash 8 the timer automatically started i already give menu to my game before entering into race game the timer starts at menu frame... i have 1 frame for menu and 2nd frame for car(whiche have all action scripts including timer script) and 3rd frame is for game over menu am also using dynamic text and var name is _root.totaltime the problem is my timer is not stopping still continues its time even game is over when i hit enter the car will reset but my timer is not reseting its start time which left at last.... here is my action script for car:

onClipEvent(load) 
{
speed = 0;
acceleration = 0.4;
speedDecay = 0.96;
maxSpeed = 10;
backSpeed = 1;
lap = 1;
totallaps = 4;
var fulllap:Boolean = false;
}

onClipEvent(enterFrame) {
    if(Math.abs(speed) > 0.3) { 
        speed *= speedDecay;
    }else {
        speed = 0;
    }
    if(Key.isDown(Key.UP)) {
        if (Math.abs(speed) >= maxspeed) {
            speed += acceleration;
            }
        }
    if(Key.isDown(Key.DOWN)) {
        if(speed < 0.5) 
        speed = -2;
        else
        speed--;
    }
        if (Math.abs(speed)> 0.5) {
        if (Key.isDown(Key.LEFT)) {
            _rotation -= 10;
         }
         if (Key.isDown(Key.RIGHT)) {
            _rotation += 10;
            }
        }
       x = Math.sin(_rotation*(Math.PI/180))*speed;
       y = Math.cos(_rotation*(Math.PI/180))*speed*-1;

       if (!_root.ground.hitTest(_x+x, _y+y, true)) {
       _x += x;
       _y += y;
       }else {
        speed -= speed*1.5;   
       }
}

onClipEvent(enterFrame) {
    if (_root.checkpoint1.hitTest(this)) {
        if(fulllap){
            if(lap >= totallaps)
                ++lap;
            fulllap = false;

        }   
    }
    if (_root.checkpoint2.hitTest(this)) {
        fulllap = true;
    }
    _root.currentlap = lap + "/" + totallaps;

    seconds = Math.floor(getTimer()/1000);
    minutes = Math.floor(seconds/60);
    tens = Math.round((getTimer()-seconds*1000)/10);

    if(minutes < 10) {
        minutes = "0" + minutes;
    }
    if (seconds < 10) {
        seconds = "0" + seconds;
    }
    if (tens < 10 ) {
        tens = "0" + tens;
    }

    _root.totaltime = minutes + "." + seconds + "." + tens;
    _root.totaltime.stop();
if(Key.isDown(Key.ENTER)) 
{
    _root.totaltime.start();
}
    }

the timer is not reseting.The timer is still continues even if game is over

1
Punctuation would be extremely helpful.Brent

1 Answers

0
votes

I'm guessing you are using ActionScript 2? As far as I can see, the script to stop the timer is working perfectly fine. However, that is all your script does: stopping the timer. It isn't actually resetting it.