O'Reilly logo

ActionScript: The Definitive Guide by Colin Moock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

XMLSocket Class — support for a continuous server/client TCP/IP connection

Availability

Flash 5

Constructor

new XMLSocket( )

Methods

close( )

Terminate an open connection to a server application.

connect( )

Attempt to establish a new connection to a server application.

send( )

Send an XML object hierarchy to a server application as a string.

Event handlers

onClose( )

Executes when the server terminates the connection.

onConnect( )

Executes when a connection attempt completes.

onData( )

Executes when data is received but has not yet been parsed as XML.

onXML( )

Executes when data has been received and parsed into an XML object hierarchy.

Description

The majority of connections between Flash and a server have a very short life span. When Flash requests external data via the loadMovie( ), loadVariables( ), or XML.load( ) functions, a temporary communication channel is established. Data is sent over that channel and then the channel is terminated. This kind of short-term communication has many useful applications, but it is also limited in two important ways:

  • Once the connection closes, the server has no way of contacting Flash. Flash must always initiate communication with the server.

  • Each time Flash obtains information from the server, a new connection must be opened. The time and processor load involved in opening repeated connections prevents Flash from engaging in anything near real-time transactions with a server.

As of Flash 5, we can overcome these limitations with the XMLSocket class, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required