Jump to content
Search Community

VideoLoader.as:276 ** NetConnection.connect

DOURADO test
Moderator Tag

Recommended Posts

Hola Jack,

 

I'm trying to load a video but I'm getting this error:

Error: Error #2132: NetConnection.connect cannot be called from a netStatus event handler.

at flash.net::NetConnection/connect()

at com.greensock.loading::VideoLoader()[/WORK/Vil/Flash/com/greensock/loading/VideoLoader.as]

at jd::HomeBackgroundGp()[/WORK/Vil/Flash/jd/HomeBackgroundGp.as] //..... here is where the code is....

at jd::Main$cinit()

at global$init()[/WORK/Vil/Flash/jd/Main.as]

 

 

 

The code:

 

addChild(videoContainer);

 

videoContainer.addChild(videoSprite1);

 

 

//create a VideoLoader

var loaderVideo1:VideoLoader = new VideoLoader("assets/consejo1.flv", {name:"myVideo", container:videoSprite1, width:980, height:580, scaleMode:"proportionalInside", bgColor:0x000000, autoPlay:false, volume:0, estimatedBytes:160000, onComplete:completeHandler});

 

//Or you could put the VideoLoader into a LoaderMax. Create one first...

var queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler});

 

//append the VideoLoader and several other loaders

queue.append( loaderVideo1 );

 

//start loading the LoaderMax queue

queue.load();

 

function progressHandler(event:LoaderEvent):void {

trace("progress: " + event.target.progress);

}

 

function completeHandler(event:LoaderEvent):void {

//play the video

loaderVideo1.playVideo();

 

//tween the volume up to 1 over the course of 2 seconds.

TweenLite.to(loaderVideo1, 2, {volume:1});

}

 

function errorHandler(event:LoaderEvent):void {

trace("error occured with " + event.target + ": " + event.text);

}

 

 

//end

I guess that I'm missing something..

Do we have to import the usual packages for playing video or any other type of package or class?

 

Thanks!!

Link to comment
Share on other sites

No, you don't need to import other classes like NetStream or NetConnection just to use VideoLoader. I tested your code and it worked fine for me. No errors at all. One slightly odd thing was that you set both your VideoLoader's onComplete and your LoaderMax queue's onComplete to the same method, but maybe that was intentional.

 

Anyway, I suspect there may be a problem elsewhere in your code. If you're still running into trouble, please post a simplified FLA that demonstrates the issue.

Link to comment
Share on other sites

Hy Jack,

 

Once more thanks for such a fast answer.

 

I just made a new FLA document width the code:

 

//create a VideoLoader

var loaderVideo1:VideoLoader = new VideoLoader("assets/consejo1.flv", {name:"myVideo", container:videoSprite1, width:980, height:580, scaleMode:"proportionalInside", bgColor:0x000000, autoPlay:false, volume:0, estimatedBytes:160000, onComplete:completeHandler});

 

loaderVideo1.load();

 

function completeHandler(event:LoaderEvent):void

{

//play the video

loaderVideo1.playVideo();

//tween the volume up to 1 over the course of 2 seconds.

TweenLite.to(loaderVideo1, 2, {volume:1});

}

 

to load the video and it work's.

I have no idea why I have the netConnection problem. Before the video I have to many things loading..

If I comment the code it work's just fine... :?

 

I also have some youtube videos running in the app but in different class.

Can this be a problem?

 

Note: I'm using CS5 running on mac and for more than one time I'm having problems and the program closes.. Especially when I'm using external calls or calling to external APIs like youtube or facebook.

 

 

I will look for something missing.. if I can't find any I will mail you the code.

Thank you.

Link to comment
Share on other sites

Hy Jack,

 

Well I think it's scope problem.

I made some tests with youtube videos and it works just fine.

It seems somehow that if we wait to the first content to be loaded it works, doesn't make to much sense.

 

If you think it's necessary I can send you the "big code".

 

Thank's once more.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...