
XMLSocket.send() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Alphabetical Language Reference
|
961
To access the raw data sent over a socket, override the default behavior of the socket’s
onData() handler (see XMLSocket.onData()).
Example
To respond to an onXML() event, we must assign our own callback function to the onXML
property of an XMLSocket object. The following code assigns the function handleIncoming()
to
mySocket’s onXML property. The handleIncoming() function accesses one of the nodes of the
XML object hierarchy stored in
messageObj and adds its value to the text field messages_txt:
mySocket = new XMLSocket();
mySocket.onXML = handleIncoming;
function handleIncoming (messageObj) {
trace("Got some new data!");
// messageObj will contain the fragment: <MESSAGE>text</MESSAGE>
var message = messageObj.firstChild.firstChild;
messages_txt.text += (message.nodeValue + "\n");
}
For code showing the onXML() handler used in a more complete system, see Example R-11
under the XMLSocket class.
See Also
XMLSocket.send(), XMLSocket.onData(); Chapter 10
XMLSocket.send() Method
transmit XML-formatted data to a server application
Flash 5
socket.send(xmlObject)
Arguments
xmlObject An XML object to be converted into a string and sent to the server applica-
tion or any string containing XML-formatted text.
Description
The send() method transmits ...