I have a NetConnection object:
myNetConnection = new NetConnection();
myNetConnection.addEventListener(NetStatusEvent.NET_STATUS, statusHandler);
myNetConnection.connect("rtmp://address");
And in handler do this:
private function statusHandler(event:NetStatusEvent):void
{
switch (event.info.code)
{
case "NetConnection.Connect.Success":
{
trace("ok");
break;
}
case "NetConnection.Connect.Failed":
{
trace("Some problems, NetConnection.Connect.Failed");
break;
}
}
}
So, if all ok - I have see "ok" in debug console very fast. But if have any problems - "Some problems, NetConnection.Connect.Failed" I see after long time waiting. My question - how i can see "Some problems, NetConnection.Connect.Failed" faster(as "ok" fast)?
You most likely can't. The event is triggered as fast as it can be, it's the connection failure that is taking a long time to manifest itself.
It looks to me like the problem is that the connection attempt times out. Flash tries to connect and sets a timer, if the timer fires before the connection is established Flash concludes that the resource is not available. You can't get a failure at once, because the connection does not fail until the timer has fired.
Flash can't tell you immediately that the resource is not available because sometimes a server responds within milliseconds, but sometimes it can take seconds.