03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example<br />

The following function overrides the default implementation of the onXML() method in a<br />

simple chat application. The myOnXML() function instructs the chat application to recognize a<br />

single XML element, MESSAGE, in the following format:<br />

.<br />

var socket:XMLSocket = new XMLSocket();<br />

In the following example, the displayMessage() function is assumed to be a user-defined<br />

function that displays the message that the user receives:<br />

socket.onXML = function (doc) {<br />

var e = doc.firstChild;<br />

if (e != null && e.nodeName == "MESSAGE") {<br />

displayMessage(e.attributes.user, e.attributes.text);<br />

}<br />

}<br />

See also<br />

Array function<br />

send (XMLSocket.send method)<br />

public send(data:Object) : Void<br />

Converts the XML object or data specified in the object parameter to a string <strong>and</strong> transmits<br />

it to the server, followed by a zero (0) byte. If object is an XML object, the string is the<br />

textual representation of the XML object. The send operation is asynchronous; it returns<br />

immediately, but the data can be transmitted at a later time. The XMLSocket.send() method<br />

does not return a value indicating whether the data was successfully transmitted.<br />

If the XMLSocket object is not connected to the server (using the XMLSocket.connect()<br />

method), the XMLSocket.send() operation fails.<br />

Parameters<br />

data:Object - An XML object or other data to transmit to the server.<br />

Example<br />

The following example shows how to specify a user name <strong>and</strong> password to send the my_xml<br />

XML object to the server:<br />

var myXMLSocket:XMLSocket = new XMLSocket();<br />

var my_xml:XML = new XML();<br />

var myLogin:XMLNode = my_xml.createElement("login");<br />

myLogin.attributes.username = usernameTextField;<br />

myLogin.attributes.password = passwordTextField;<br />

XMLSocket 721

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!