Skip to main content
August 30, 2007
Answered

ActionScript 2.0 vs 3.0 NetConnection

  • August 30, 2007
  • 1 reply
  • 470 views
I have some code I've been using to connect to a streaming server. This version is compiled for ActionScript 2.0:
----
netConnection = new NetConnection();
netConnection.onStatus = function(info) {
trace("status: " + info.code);
};
netConnection.connect("rtmp://server.net/blah/blah/");
----
When I run that, I get "status: NetConnection.Connect.Success" and everything works like it should.


Now, I run what seems to me to be pretty much identical code, compiled for ActionScript 3.0:
----
var netConnection:NetConnection = new NetConnection();
netConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
netConnection.connect("rtmp://server.net/blah/blah/");

function netStatusHandler(event:NetStatusEvent):void {
trace("status: " + event.info.code);
}
----
When I run that, though, I get:
status: NetConnection.Connect.Rejected
status: NetConnection.Connect.Closed

I've tried using port 1935 as suggested here, and that didn't help. I also tried uploading this to my server to see if it was the firewall on my machine. Same problem. I CAN connect using the FLVPlayBack control under ActionScript 3.0, but I'd rather use this method...

But honestly, the only real difference is the switch from AS2.0 to 3.0. What could possibly be different to make the server reject my connection? Is there some other way I'm supposed to connect with 3.0? I've found surprisingly little info on the subject.

If it's something on the server itself, please explain slowly with small words. 🙂 I know nothing about the server itself, don't have direct access to it, and will have to be able to explain the problem to their admin.
    This topic has been closed for replies.
    Correct answer ramindeja
    Try adding this code:

    netConnection.objectEncoding = ObjectEncoding.AMF0;

    before connecting since that's the encoding of the current FMS 2 encoding.

    1 reply

    ramindejaCorrect answer
    Inspiring
    August 30, 2007
    Try adding this code:

    netConnection.objectEncoding = ObjectEncoding.AMF0;

    before connecting since that's the encoding of the current FMS 2 encoding.
    August 30, 2007
    That's it! Thank you so much!