Some URGENT Help needed please...

I try to put my words into code,
In short, guiTexture is recognized as movTexture in function start part, but not in the OnGUI part…
There is also a package containing scene at the end…

Thanks to all responders…

var url = "http://www.digimed.com.tr/fuarassets/video/ardex.ogg";
var mygui : GUITexture;
mygui = GetComponent (GUITexture);

var bgr : GUITexture;
var btn0 : GUITexture;
var btn1 : GUITexture;
var btn2 : GUITexture;
var btn3 : GUITexture;
var btn4 : GUITexture;
var btn5 : GUITexture;

mygui.enabled = true;
bgr.enabled = true;
btn0.enabled = true;
btn1.enabled = true;
btn2.enabled = true;
btn3.enabled = true;
btn4.enabled = true;
btn5.enabled = true;

function Start () {
    var www = new WWW(url);
    var movTexture = www.movie;
    while (!movTexture.isReadyToPlay)
        yield;      

	mygui.mainTexture = movTexture;
    // this was, guiTexture.texture = movieTexture;
	// I just change it to play my video at where I want.
    
    audio.clip = movTexture.audioClip; 
	movTexture.Play();
    // Here I am very confused... When I disable function OnGUI part 
	// below, it works. But now it gives this error:
	
	// NullReferenceException: Object reference not set to an instance of an object
	
	audio.Play();
}
@script RequireComponent (GUITexture)
@script RequireComponent (AudioSource)

function OnGUI() {
    if(btn2){
    if (mygui.mainTexture.isPlaying) {
        mygui.mainTexture.Pause();
		btn2 = btn1;
		}
		
        else {
		mygui.mainTexture.Play();
		btn2 = btn0;
        }  

    }   
	
    if(btn3){
        mygui.mainTexture.Stop();       
		btn2 = btn1;
    }    

    if(btn4){
        mygui.mainTexture.Stop();       
		btn2 = btn1;
    }    

    if(btn5){
		mygui.mainTexture.Stop();
		mygui.enabled = false;
		bgr.enabled = false;
		btn0.enabled = false;
		btn1.enabled = false;
		btn2.enabled = false;
		btn3.enabled = false;
		btn4.enabled = false;
		btn5.enabled = false;
	}
	
}
// I tried almost every possible combination, but my scene 
// doesnt like this OnGUI stuff :)

1076116–40187–$webvideo_w_controller_try2.unitypackage (41.8 KB)

I dont think GUITexture has a mainTexture property , change it back to “texture” also you cant reference the “texture” field of GUITexture as the MovieTexture itself as Im sure it is downcast to a Texture object at that point. Try creating your variable for the MovieTexture as a class field ( not in the start function ) then call the relevant methods on that variable in your OnGUI function.

Well I did not clearly understand. I am very new on javascript and unity also…
Will you please give some example with a few lines…

thx

var url = "http://www.digimed.com.tr/fuarassets/video/ardex.ogg";

var mygui : GUITexture;

mygui = GetComponent (GUITexture);

 

var bgr : GUITexture;

var btn0 : GUITexture;

var btn1 : GUITexture;

var btn2 : GUITexture;

var btn3 : GUITexture;

var btn4 : GUITexture;

var btn5 : GUITexture;

 

mygui.enabled = true;

bgr.enabled = true;

btn0.enabled = true;

btn1.enabled = true;

btn2.enabled = true;

btn3.enabled = true;

btn4.enabled = true;

btn5.enabled = true;

var movTexture : MovieTexture

function Start () {

    var www = new WWW(url);

    movTexture = www.movie;

    while (!movTexture.isReadyToPlay)

        yield;      

 

    mygui.texture = movTexture;

   

    

    audio.clip = movTexture.audioClip; 

    movTexture.Play();    

    audio.Play();

}

@script RequireComponent (GUITexture)

@script RequireComponent (AudioSource)

 

function OnGUI() {

    if(btn2){

    if (movTexture.isPlaying) {

        movTexture.Pause();

        btn2 = btn1;

        }

        

        else {

        movTexture.Play();

        btn2 = btn0;

        }  

 

    }   

    

    if(btn3){

        movTexture.Stop();       

        btn2 = btn1;

    }    

 

    if(btn4){

        movTexture.Stop();       

        btn2 = btn1;

    }    

 

    if(btn5){

        movTexture.Stop();

        mygui.enabled = false;

        bgr.enabled = false;

        btn0.enabled = false;

        btn1.enabled = false;

        btn2.enabled = false;

        btn3.enabled = false;

        btn4.enabled = false;

        btn5.enabled = false;

    }

    

}

I thank you very much… And thank your time spend.

There was still some problems in the OnGUI part, I think the way of creating buttons crashed somethings…

instead of the one above, I use this…

function OnGUI () {
    if(GUI.Button(Rect(452,453,58,58),"",bt2)){
    if (movTexture.isPlaying) {
        movTexture.Pause();     
        bt2=bt1;
        }			
        else {
        movTexture.Play();
        bt2=bt0;            
        }
    }
}

THANK YOU AGAIN!!!