FANDOM


XMLSocket is a class in ActionScript which allows Adobe Flash content to use socket communication. It can be used for plain text, although, as the name implies, it was made for XML. It is often used in chat applications and multiplayer games.

Examples Edit

ActionScript 2.0 Edit

For a simple Hello, World! application in ActionScript 2.0, you could use the code below:

var xmlSocket:XMLSocket=new XMLSocket();
xmlSocket.onConnect=function() {
    xmlSocket.send(new XML("<message><text>Hello, World!</text></message>"));
}
xmlSocket.onXML=function(myXML) {
    trace(myXML.firstChild.childNodes[0].firstChild.nodeValue);
    xmlSocket.close();
}
xmlSocket.connect("localhost",8463);

This would result in the output window of the Flash IDE opening and displaying "Hello, World!", assuming that a socket server was running on port 8463 of the local machine, and was echoing everything sent to it. </pre>

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.