
ADOBE FLASH MEDIA INTERACTIVE SERVER
Server-Side ActionScript Language Reference
150
socket.onConnect = myOnConnect;
socket.connect(null,2000);
function myOnConnect(success) {
if (success) {
trace("Connection success")
} else {
trace("Connection failed")
}
}
XMLSocket.onData()
myXMLSocket.onData = function(src) {}
Invoked when a message has been downloaded from the server, terminated by a zero (0) byte. You can override
XMLSocket.onData() to intercept the data sent by the server without parsing it as XML. This is useful if you’re
transmitting arbitrarily formatted data packets and you would prefer to manipulate the data directly when it arrives,
rather than have Flash Media Interactive Server parse the data as XML.
By default, the
XMLSocket.onData() method invokes the XMLSocket.onXML() method. If you override
XMLSocket.onData() with custom behavior, XMLSocket.onXML() is not called unless you call it in your imple-
mentation of
XMLSocket.onData().
Availability
Flash Media Server 2
Parameters
src A string containing the data sent by the server.
Example
In the following example, the
src parameter is a string containing XML text downloaded from the server. The zero-
byte (0) terminator is not included in the string.
XMLSocket.prototype.onData = function (src) {
this.onXML(new XML(src));
}
XMLSocket.onXML()
myXMLSocket.onXML = function(object) {}
Invoked when the specified XML object containing an XML document arrives through an open XMLSocket
connection. An XMLSocket connection can be used to transfer an unlimited number of XML documents between
the client and the server. Each document is terminated with a zero (0) byte. When Flash Media Interactive Server
receives the zero byte, it parses all of the XML received since the previous zero byte or, if this is the first message
received, since the connection was established. Each batch of parsed XML is treated as a single XML document and
passed to the
onXML() handler.
The default implementation of this method performs no actions. To override the default implementation, you must
assign a function containing actions that you define.
Availability
Flash Media Server 2
Commenti su questo manuale