Name
XMLSocket.onData( ) Event Handler — executed when external data is received,but has not yet been parsed as XML
Availability
Flash 5 (undocumented)
Synopsis
socket.onData(src)
Arguments
- src
A string containing loaded data, which is usually XML source code.
Description
The onData( )
handler executes automatically
whenever a
zero byte (ASCII null character) is
transmitted to Flash over socket
. By
default, onData( )
simply constructs a new XML
object hierarchy from src
, and passes that
hierarchy to socket.onXML( )
. However, the
onData( )
handler may be assigned a custom
callback function to intercept src
before
ActionScript has a chance to parse it as XML. Under certain
circumstances (such as real-time video games), manipulating the raw
data in src
manually may offer improved
performance over ActionScript’s built-in XML parsing.
Example
The following code shows how to assign a custom callback function to
onData( )
. The callback function simply displays
any data received by mySocket
and prevents
ActionScript from parsing the data as XML:
mySocket = new XMLSocket(); mySocket.onData = function (src) { trace("Received data: \n" + src); };
See Also
XMLSocket.onXML( )
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.