
XMLSocket.onData() Event Handler
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Alphabetical Language Reference
|
959
Arguments
success A Boolean indicating whether the connection attempt succeeded (true)or
failed (
false).
Description
The onConnect() event handler is executed when a previously invoked connect() operation
finishes. The execution of onConnect() does not necessarily mean a connection has been
successfully established—it is executed whenever the connection attempt finishes, whether
or not the attempt was successful. The callback handler specified by onConnect() is passed
a
success argument that indicates if the attempt succeeded (i.e., a connection has been
established). If so,
success is set to true. If the attempt failed (i.e., a connection timed out,
was refused, or otherwise could not be established), the
success argument is set to false.
Note that ActionScript does not distinguish among network timeout, unknown host,
refusal, or other common connection errors. Therefore, the callback handler may not be
executed for up to a minute after the connect() command is issued, depending on the
settings of the server involved in a connection attempt, the connection speed, network
traffic, and so on.
Example
We use onConnect() to detect the success or failure of a connection attempt. In practice, we
might use it to set a flag indicating ...