
Код:
…
socket.addEventListener(IOErrorEvent.IO_Error, this.handler_ioError);
…
private var _attempts:uint = 0;
private var _timeoutID:uint;
private function connect():void {
this._attempts++;
try {
socket.connect(…);
} catch (error:Error) {
this.attempt();
}
}
private function attempt():void {
if (this._attempts > 2) {
// bla-bla, показываем ошибку
} else {
this.showMessage("Error", "Connection failed", Message.OK);
}
}
private function handler_ioError(event:IOErrorEvent):void {
this.attempt();
}
private function handler_okClick(event:Event):void {
this.hideMessage();
this.connect();
}
Как-то так. Рекурсии не будет. В чем проблема?