Groups | Blog | Home
all groups > macromedia flash flashcom > october 2006 >

macromedia flash flashcom : ArgumentError: Error #2126: NetConnection object must be connected.


thedavid
10/30/2006 12:00:00 AM
I have a windows xp computer and a windows 2003 server computer connected with
a single network cable. I am running Flash Media Server on the server
computer. My Flex Builder 2 application can connect to the Flash Media Server
on the other computer, but I always get the following error when trying to use
NetStream:

nc.connect("rtmp://pb.local:1935/flexmediaservertest");

nsPublish = new NetStream(nc);
....

ArgumentError: Error #2126: NetConnection object must be connected.

What might be causing this error?

Melvin_Draco
10/30/2006 2:29:18 PM
do you watch the onStatus event? Try something like this:

nc = new NetConnection();
nc.onStatus = function(info) {
// trace("Level: " + info.level + " Code: " + info.code);
if (info.code == "NetConnection.Connect.Success") {
//trace("--- connected to: "+this.uri);

nsPublish = new NetStream(nc);

} else if (info.code == "NetConnection.Connect.Failed" || info.code ==
"NetConnection.Connect.Closed") {
trace("--- No connection to app");
}
};
nc.connect("rtmp://pb.local:1935/flexmediaservertest");
thedavid
10/31/2006 1:40:22 AM
Thanks for the reply. Actually today I tried to ping my server "pb.local:1935"
and got no response. I have used "netstat -a" on the server and
"pb.local:1935" is listening. So I guess my problem is a port connection.
thedavid
10/31/2006 1:54:30 PM
After banging my head against the computer for 3 days, I finally got my
application working, but not with Flex Builder 2. I got it workin with Flash
8. There must be some problem between Actionscript3 and FMS2.
Melvin_Draco
10/31/2006 11:05:09 PM
sorry about my last piece of code.... i forgot you are coding in AS3 - have
some trickies.... but the logic still same... is a good chooice, always, make
sure you have succeded connection.....


NetConnection.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0;

private function init():void{
// Create the NetConnection and listen for NetStatusEvent and
SecurityErrorEvent events
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, netSecurityError);
nc.connect("rtmp://pb.local:1935/flexmediaservertest");
}

private function netStatus(event:NetStatusEvent):void {
trace("netStatus: " + event);
var info:Object = event.info;
trace(info.code);
if (info.code == "NetConnection.Connect.Success") {
// lots more code here...
// CALL YOUR PUBLISH FUNCTION HERE.
}
}

private function netSecurityError(event:SecurityErrorEvent):void {
trace("netSecurityError: " + event);
}



I hope that's all....
thedavid
11/2/2006 7:57:52 PM
Thanks, yes I have it working now. But still one problem:-

When running a Flex Builder 2 application in Internet Explorer and when
disconnecting the client application's video stream from the Flash Media Server
and closing the Internet Explorer Browser, the Internet Explorer Process
continues to run in the background, ie: you can see it using Task Manager and
must be terminated manually. So after testing the application several times, I
have several instances of Internet Explorer all running in the background. Is
there a cure for this?
thedavid
11/4/2006 9:42:55 PM
[q][i]Originally posted by: [b][b]thedavid[/b][/b][/i]
Thanks, yes I have it working now. But still one problem:-

When running a Flex Builder 2 application in Internet Explorer and when
disconnecting the client application's video stream from the Flash Media Server
and closing the Internet Explorer Browser, the Internet Explorer Process
continues to run in the background, ie: you can see it using Task Manager and
must be terminated manually. So after testing the application several times, I
have several instances of Internet Explorer all running in the background. Is
there a cure for this?[/q]

Apologies, this turned out to be a Windows XP faulty installation problem.
AddThis Social Bookmark Button