dimanche 26 février 2017

ActionScript 2 and Sockets using mtasc on Linux

How can I correctly implement in ActionScript 2 connecting to a socket and sending some data? I tried many variants of code, but still there is the same error:

file.as:13: characters 0-9 : parse error Unexpected theSocket.

I'm trying to compile a file using mtasc -swf some.swf -main -header 800:600:20 file.as.

class Tuto {

static var app : Tuto;

function sendData() {
var myXML:XML = new XML();
var mySend = myXML.createElement("thenode");
mySend.attributes.myData = "some data";
myXML.appendChild(mySend);
theSocket.send(myXML);
}

theSocket.onConnect = function(myStatus) {
if (myStatus) {
    conn_txt.text = "connection successful";
} else {
    conn_txt.text = "no connection made";
}

function Tuto() {
var theSocket:XMLSocket = new XMLSocket();
theSocket.connect("localhost", 5555);
_root.createTextField("tf",0,0,0,800,600);
_root.tf.text = "Hello world !";

sendData();

}
};

static function main(mc) {
    app = new Tuto();
}
}

Aucun commentaire:

Enregistrer un commentaire