MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT Reference Manual page 779

Actionscript reference guide
Hide thumbs Also See for FLASH MX 2004 - ACTIONSCRIPT:
Table of Contents

Advertisement

Example
The following example illustrates the process of specifying a replacement function for the
method in a simple chat application.
onConnect
The function controls which screen users are taken to, 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
with troubleshooting information on the frame labeled
function myOnConnect(success) {
if (success) {
gotoAndPlay("startChat")
} else {
gotoAndStop("connectionFailed")
}
}
After creating the XMLSocket object using the constructor method, the script installs the
method using the assignment operator:
onConnect
socket = new XMLSocket();
socket.onConnect = myOnConnect;
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.
if (!socket.connect(null, 2000)) {
gotoAndStop("connectionFailed")
} else {
gotoAndStop("waitForConnection")
}
See also
,
function
XMLSocket.connect()
XMLSocket.onData()
Availability
Flash Player 5.
Usage
XMLSocket.onData = function(src) {
// your statements here
}
Parameters
A string containing the data sent by the server.
src
Returns
Nothing.
. If the connection is not successful, users go to a screen
startChat
connect()
, and
connectionFailed
waitForConnection
connectionFailed
returns
, the SWF file is sent directly to
false
is never invoked. If
onConnect
waitForConnection
frame until the
.
returns
connect()
, which is the "Please wait"
handler is
onConnect
XMLSocket.onData()
779

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Table of Contents