Name

XMLSocket.onConnect( ) Event Handler — defines the event handler invoked when a connection attempt is completed, successfully or otherwise

Availability

Flash 5

Synopsis

socket.onConnect = connectHandler
socket.connectHandler(success  )

Arguments

success

A Boolean indicating whether the connection attempt succeeded (true) or failed (false).

Description

The onConnect property allows you to specify a callback handler to be executed automatically when a previously invoked connect( ) operation finishes. The execution of the callback handler specified by onConnect does not necessarily mean a connection has been successfully established—the callback handler is executed whenever the connection attempt is finished, 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. The callback handler, therefore, 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 the callback handler specified by onConnect ...

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.