EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 662

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
662 Working with External Data
The following example creates an XML socket connection and sends data from the XML
object
myXML. To understand the script, read the commented lines (indicated by the characters
//):
// Create XMLSocket object
var theSocket:XMLSocket = new XMLSocket();
// Connect to a site on unused port above 1024 using connect() method.
// Enter localhost or 127.0.0.1 for local testing.
// For live server, enter your domain www.yourdomain.com
theSocket.connect("localhost", 12345);
// displays text regarding connection
theSocket.onConnect = function(myStatus) {
if (myStatus) {
conn_txt.text = "connection successful";
} else {
conn_txt.text = "no connection made";
}
};
// data to send
function sendData() {
var myXML:XML = new XML();
var mySend = myXML.createElement("thenode");
mySend.attributes.myData = "someData";
myXML.appendChild(mySend);
theSocket.send(myXML);
}
// button sends data
sendButton.onRelease = function() {
sendData();
};
// traces data returned from socket connection
theSocket.onData = function(msg:String):Void {
trace(msg);
};
For more information, see the XMLSocket entry in the ActionScript 2.0 Language
Reference.
For more information on local file security, see About local file security and Flash Player
on page 679.

Table of Contents

Related product manuals