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;

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.

try this

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