User Guide
XMLSocket 1345
Example
The following example uses
XMLSocket.connect() to connect to the host where the SWF
file resides and uses
trace to display the return value indicating the success or failure of
the connection:
var socket:XMLSocket = new XMLSocket()
socket.onConnect = function (success:Boolean) {
if (success) {
trace ("Connection succeeded!")
} else {
trace ("Connection failed!")
}
}
if (!socket.connect(null, 2000)) {
trace ("Connection failed!")
}
See also
onConnect (XMLSocket.onConnect handler), function statement
onClose (XMLSocket.onClose handler)
onClose = function() {}
Invoked only when an open connection is closed by the server. The default implementation of
this method performs no actions. To override the default implementation, you must assign a
function containing custom actions.
Availability: ActionScript 1.0; Flash Player 5
Example
The following example executes a trace statement if an open connection is closed by the
server:
var socket:XMLSocket = new XMLSocket();
socket.connect(null, 2000);
socket.onClose = function () {
trace("Connection to server lost.");
}
See also
onConnect (XMLSocket.onConnect handler), function statement