我有以下代码。在onClientClose方法中,我想从_clientSockets数组中删除_socketServicer实例。如果我不知道它的索引,我如何引用数组中的_socketServicer实例?
public function connectHandler(event:ServerSocketConnectEvent):void { _socketServicer=new SocketService(event.socket, this,log);
_socketServicer.addEventListener(Event.CLOSE, onClientClose);
_clientSockets.push(_socketServicer); //maintain a reference to prevent premature garbage collection
}
private function onClientClose(event:Event):void {
//Nullify references to closed sockets
for each (var servicer:SocketService in _clientSockets) {
if (servicer.closed)
servicer=null;
}
}