apache-flexnetconnection

flex 3: netconnection - how do i set a timeout?


Using flex 3, how do i set a timeout for a NetConnection?

code sample:

 nc=new NetConnection();
 nc.addEventListener (NetStatusEvent.NET_STATUS,checkConnect);
 rtmpNow="rtmpe://host/test/test1";         
 nc.connect(rtmpNow,fuid,gameName);

Solution

  • Unless you plan to wait for a NetConnection.Connect.Failed, I believe you have to setup your own timeout checks.

    Using a Timer object, you can check upon Timer.TIMER_COMPLETE whether or not you've received a NetConnection.Connect.Success in your checkConnect function.

    Can't think of another way to do this.