How can i dynamically change texture

Hello Everyone,

Does someone know what is the syntax for UITexture?
I have this code below but i do get this error upon hitting start?
"NullReferenceException: Object reference not set to an instance of an object
ChangeTextureImageBox.Start () "

    UITexture textureComponent = GetComponent<UITexture>();
    textureComponent.mainTexture = Resource.Load("texturename") as Texture;
    textureComponent.MakePixelPerfect(); 

What i want to do is dynamically change the texture of object through condition.
Any advice and tips would be much appreciated, BTW that is a class from UIWidget from NGUI. http://tasharen.com/ngui/docs/class_u_i_texture.html

try this

 var normalTexture : Texture2D;
    var rollOverTexture : Texture2D;
    
    function OnMouseDown(){
//or you could just have your condition instead
    guiTexture.texture=rollOverTexture;
    yield new WaitForSeconds(4);//or a reverse condition
    guiTexture.texture=normalTexture;

    }