XMLSocket.onClose( ) Event Handler

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'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



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net