ActionScript for Flash MX: The Definitive Guide, 2nd Edition By Colin Moock
Chapter 18. ActionScript Language Reference
XMLSocket.onClose( ) Event Handler
Flash 5
invoked when the server closes the connection
socket.onClose()
Description
The onClose( ) event handler is executed whenever an open connection to socket is closed by the server (not by Flash). Server-instigated closures usually result from a server application shutting down or deliberately "kicking off" the client.
Example
To respond to an onClose( ) event, we must assign our own function (i.e., our callback handler) to the onClose property of an XMLSocket object. We use the callback handler to detect an external socket disconnection. The following code assigns the function handleClose( ) to mySocket'sonClose property. The handleClose( ) function simply alerts the user that a closure has occurred by updating the value of the text field status_txt:
mySocket = new XMLSocket(); mySocket.onClose = handleClose; function handleClose () { status_txt.text += ("\nThe server has terminated the connection.\n"); }