texture tiling question

Ive made a tank and have the treads animated by tiling the textures
I cant figure out how to make the treads stop turning when the tank stops
here is the script i use to rotate the treads

var uvAnimationTileX = 24; //Here you can place the number of columns of your sheet.
//The above sheet has 24

var uvAnimationTileY = 1; //Here you can place the number of rows of your sheet.
//The above sheet has 1
var framesPerSecond = 10.0;

function Update () {

// Calculate index
var index : int = Time.time * framesPerSecond;
// repeat when exhausting all frames
index = index % (uvAnimationTileX * uvAnimationTileY);

// Size of every tile
var size = Vector2 (1.0 / uvAnimationTileX, 1.0 / uvAnimationTileY);

// split into horizontal and vertical index
var uIndex = index % uvAnimationTileX;
var vIndex = index / uvAnimationTileX;

// build offset
// v coordinate is the bottom of the image in opengl so we need to invert.
var offset = Vector2 (uIndex * size.x, 1.0 - size.y - vIndex * size.y);

renderer.material.SetTextureOffset ("_MainTex", offset);
renderer.material.SetTextureScale ("_MainTex", size);

}

can someone help me make the change to this script
i really dont know what to do

thanks

wayne

How about this: instead of using Time.time to determine the current frame, use an internal timer that gets incremented only when the tank is moving?

private var currentAnimTime : float;
var relativeAnimationSpeed : float;
var previousPosition : Vector3; // allow the animation to adjust for speed
function Update()
{
    var distanceTravelled : float = Vector3.Distance(previousPosition, transform.position);
    currentAnimTime += (distanceTravelled * relativeAnimationSpeed)

    var index : int = currentAnimTime * framesPerSecond;

    // the rest is the same
}