XMLSocket.onData( ) Event Handler

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
XMLSocket.onData( ) Event Handler Flash 5

executed when external data is received but has not yet been parsed as XML
socket.onData(src)

Arguments

src

A string containing loaded data, which is usually XML source code.

Description

The onData( ) event handler executes 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 can be assigned a custom callback function to intercept src before ActionScript has a chance to parse it as XML. Under certain circumstances (such as realtime 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( )



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net