Trying to code a simple animation, please help.

I made an animation it just changes between two different materials. I play the animation each time a prefab is called using getcomponent on the prefab, that seems to be working fine. My problem is I am not very fluent with the animator, and it plays all my animations right in the beginning of the scene. I try using animation.stop and animator.stopplayback I cant figure out how control the animator. I know its probably some check box, please forgive me if the answer is simple I am new! :-/

Well if its only about two material rendering then u can use my code
what it basically does is it provide sprite animation, which uses images to play
you can try it it may work for your project

#pragma strict

class SpriteAnimJS extends MonoBehaviour 
{
	var frameA				: Texture2D;	//The first frame of the animation
	var frameB 				: Texture2D;	//The second frame of the animation
	
	private var currentId 	: int 	= 0;	//The ID of the current frame
	private var canAnimate 	: boolean 	= false; //Animation enabled/disabled
	
	//Called when the object is enabled
	function OnEnable () 
	{
		//Enable the animation
		canAnimate = true;
	}
	//Called when the object is disabled
	function OnDisable()
	{
		//Stop the animation coroutine, and disable the animation
		StopCoroutine("Animate");
		canAnimate = false;
	}
	//Called on every frame
	function Update()
	{
		//If the animation is enabled
		if (canAnimate)
		{
			//Start the animation coroutine
			StartCoroutine(Animate());
		}
	}
	//The animation coroutine
	function Animate()
	{
		//Disable the calling of additional coroutines
		canAnimate = false;
		
		//Wait for 0.1 seconds
		yield WaitForSeconds(0.1f);
		
		//If the current animation frame is 0
		if (currentId == 0)
		{
			//Go to animation frame 1
			this.renderer.material.mainTexture = frameB;
			currentId = 1;
		}
		//If the current animation frame is 1
		else
		{
			//Go to animation frame 0
			this.renderer.material.mainTexture = frameA;
			currentId = 0;
		}
		
		//Enable the calling of a new coroutine
		canAnimate = true;
	}
}