disconnecting on fly
I'm disconnecting and reconnecting my app in the following way ..my problem is when i disconnect and then reconnect the client is disconnected an undesireable time however this behavior is intermittant and sometimes the application behaves as exspected and stays connected can you see where my problem is? or maybe you know a better way to construct this disconnect/reconnect function.I'm useing AS3
reconnect =0;//default value changes to 1 or 2 when function is called
reconnectIt(reconnect);
public function reconnectIt(reconnect =null):void{
if(reconnect ==2){
nc1.removeEventListener(NetStatusEvent.NETSTATUS,connecthandler);
nc1.close();
nc1.makeconnection("rtmp://domain/test/instance0");
nc1.addEventListener(NetStatusEvent.NETSTATUS,connecthandler);
}else if (reconnect==1){
nc1.removeEventListener(NetStatusEvent.NETSTATUS,connecthandler);
nc1.close();
nc1.makeconnection("rtmp://domain/test/instance1");
nc1.addEventListener(NetStatusEvent.NETSTATUS,connecthandler);
}else if (reconnect ==0){
nc1.makeconnection("rtmp://domain/test/instance0");
nc1.addEventListener(NetStatusEvent.NETSTATUS,connecthandler);
}
}
