turning animation on till its end then reseting

he, i have a script to turn on/off animation, but how can i make it turn on with a button until it finishes then reset so that next time i push that button it does the same from the start to the end im currently using this script but it ends like half way through or in the wrong place ect:

function Update () {
if(Input.GetButtonDown("Fire1")){
    animation.enabled=true;
}
if(Input.GetButtonUp("Fire1")){
    animation.enabled=false;
}

}

thanks all! :D

It might be easier to make a "do nothing" animation and then switch between them. That way you get the free fade effect and auto-rewinding:

if(Input.GetButtonDown("Fire1")){
  animation.CrossFade("walk");
}
if(Input.GetButtonUp("Fire1")){
  animation.CrossFade("stopped");
}

Have stopped be from frame 1 to 1 of walk, set to Loop (you can do that all in the Unity Inspector.) Keep animation enabled at all times, and start by playing "stopped"

If you really want to use enabled, look at `animation.Rewind`