Xmlsocket.onconnect - MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference

Actionscript language reference
Table of Contents

Advertisement

XMLSocket.onConnect

Availability
Flash Player 5.
Usage
myXMLSocket.onConnect = function(success:Boolean) {
// your statements here
}
Parameters
A Boolean value indicating whether a socket connection is successfully established
success
(
or
).
true
false
Returns
Nothing.
Description
Event handler; invoked by Flash Player when a connection request initiated through
XMLSocket.connect()
parameter is
true
The default implementation of this method performs no actions. To override the default
implementation, you must assign a function containing custom actions.
Example
The following example illustrates the process of specifying a replacement function for the
method in a simple chat application.
onConnect
After creating the XMLSocket object using the constructor method, the script defines the custom
function to be executed when the onConnect event handler is invoked. The function controls the
screen to which users are taken, depending on whether a connection is successfully established. If
the connection is successfully made, users are taken to the main chat screen on the frame labeled
. If the connection is not successful, users go to a screen with troubleshooting
startChat
information on the frame labeled
var socket:XMLSocket = new XMLSocket();
socket.onConnect = function (success) {
if (success) {
gotoAndPlay("startChat");
} else {
gotoAndStop("connectionFailed");
}
}
Finally, the connection is initiated. If
the frame labeled
, the SWF file jumps to a frame labeled
true
screen. The SWF file remains on the
invoked, which happens at some point in the future depending on network latency.
has succeeded or failed. If the connection succeeded, the
; otherwise the
success
connectionFailed
connect()
, and
connectionFailed
waitForConnection
parameter is
.
false
.
returns
, the SWF file is sent directly to
false
is never invoked. If
onConnect
waitForConnection
frame until the
success
returns
connect()
, which is the "Please wait"
handler is
onConnect
XMLSocket.onConnect 1065

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

This manual is also suitable for:

Flash mx

Table of Contents