
XMLSocket.onClose() Event Handler
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
958
|
ActionScript Language Reference
connect() method returns false for connection attempts that violate security restrictions.
Note that security restrictions do not apply to the Standalone Player.
Example
// Create a new socket object
mySocket = new XMLSocket();
// Assign a callback handler function to onConnect
mySocket.onConnect = handleConnect;
// Attempt to connect to an application running on myserver.com at port 10000
if (mySocket.connect("myserver.com", 10000) = = false) {
// Jump to a frame showing some sort of error message
this.gotoAndStop("failureDialog");
} else {
// Jump to a frame where we'll wait until onConnect() is triggered
this.gotoAndPlay("connecting");
}
See Also
XMLSocket.close(), XMLSocket.onConnect()
XMLSocket.onClose() Event Handler
invoked when the server closes the connection
Flash 5
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 applica-
tion 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 ...