New NetConnection class to resolve via rtmpt or rtmp faster via a port scan (rtmpt failback)

I have created a github code repo for official notifications and modifications of the code. Feel free to check it out here:

It seems as though something is broken.. in the flash player it's supposed to attempt a connection via rtmp and then if all else fails it should fail back to rtmpt. Well.. I had a few clients where this simply wasn't happening.

So I wrote a little class that will try rtmp first and then wait 1000ms and then try rtmpt. Which ever connects first it will use. It also supports encrypted connections via rtmpe/rtmpte.

Freely use it but if you see any issues please let me know so I can correct it for everyone else.

It's a simple use case really.. just use it as you would the built in NetConnection class. The only caveat is that for netstreams you'd need to pass in a reference to the connection and not the main class.

For example:

var client_obj:Object = new Object();
client_obj.serverMethod = function(e:Object):void
trace("server can call this");

var ncs:NetConnectionSmart = new NetConnectionSmart();
ncs.client = client_obj;
ncs.encrypted = true; //if this isn't specified it will default to rtmp/rtmpt.. if true it will try rtmpe/rtmpte

trace("connection status: ";

var ns:NetStream = new NetStream(ncs.connection);

Happy Flashing!

UPDATE: If a single port was declared as the connection path, a NetConnection.Connect.Success call would be reported twice. Added another param to declare that only the default port should be used. If you're running version prior to 0.7.8 please update.