我有以下代码。在 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;
}
}