Making an animation stop once it finishes (trouble with booleans)

My main problem is getting the animation to stop looping once the animation has finished. I use booleans to check for whether the gate should open or not, so once the boolean is true, it thinks that it should continue to repeat the animation over and over and over… and over.

I would like this script to check to see if the animation (OpenGate) has finished, but to no avail. What am I doing wrong? I thought that if I checked for that one frame where the animation would not be running, then I could stop it before it started again… any thoughts? Not sure where to go at this point.

This script makes a gate open once the target had been shot… right now I’m calling another script’s boolean (TargetShot) to set the local boolean (OpenGate) to true. Then, I want to either set the boolean to false again, OR just stop the animation… either will do.

Here’s my code!!!

#pragma strict

var OpenGate : boolean = false; //Whether or not the gate should open
var ThatObject : GameObject; //The object that contains the "TargetShot" variable.
var ThatAnim : Animation; //The object that contains the animation we need.

function Update () {

	//If the target has been shot, then the gate will open.
	if(ThatObject.GetComponent(TargetScript).TargetShot == true) {
	OpenGate = true; //This is where the problem comes in
	if(OpenGate == true) {
	Debug.Log("Opened Gate");
		//Set the mode to only play once, and then play the animation.
	ThatAnim.animation["OpenGate"].wrapMode = WrapMode.Once;
	ThatAnim.animation.Play("OpenGate"); //Our animation
		if(!=("OpenGate") || !animation.IsPlaying("OpenGate")) //If the animation finishes...
		ThatAnim.animation.Stop("OpenGate");//... Stop the animation

You should set the animation’s type to Clamp in the import settings. There are no frames during which an animation is not playing.