Table of Contents

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's onClose 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");
}

See Also

XMLSocket.close( ); Chapter 10


Table of Contents