What about
Code:
Basic XMLSocket Tutorial
Quote:
Nice of you to add that Mikey
Was that sarcasm as that was a rhetorical question. Full source is from: http://director-online.com/forums/re...?2,27812,27812
Looking forward to next tutorial...Hint Hint
XMLSocket Tutorial
This tutorial will be teaching you how to connect to a server and send data. For this tutorial we will be using mikeys multiuser server which can be downloaded here : http://www.mmoccforum.com/server-sid...html#post57041
Please note the link above is the server's source code, So you need VB6 installed to view it.
This is assuming your using Flash MX, I have not used XMLSockets in any other versions of Flash, So i don't know if they vary.
This tutorial isn't going to be to indepth, Cos im quite tired :p
First off, Open Flash.
Write some text on the canvas making sure it's static.
Then convert that into a button symbol (Opposite click and select 'Convert to symbol' then select button from the list)
Click the button once, Then goto the actions panel and put the following (I will explain the code after):
on (release) {
socket = new XMLSocket();
socket.connect("[redacted-ip]", "2300");
socket.onConnect = function(success) {
if (success) {
socket.send("HI");
}
};
}
Let's take the code apart:
on (release) {
}
This is telling us when a user releases the mouse from clicking the button, That we're going to preform the code that's inside.
socket = new XMLSocket();
This is creating a new socket called 'socket'
socket.connect("[redacted-ip]", "2300");
This is telling out socket to connect to ip address [redacted-ip] and port 2300 (Because the server is listening on port 2300 for incoming connections, and the server is being ran localhost ([redacted-ip]) )
socket.onConnect = function(success) {
};
This is telling us, When connected to the server perform the code that is inside. The 'success' will either return true (if it connected) or false (if it failed to connect)
if (success) {
socket.send("HI");
}
This code is saying if success equals true then send a packet saying 'HI'
Now if you go into the VB server and click 'ModProtocol' you'll see this:
Case "HI"
frmMain.logit "Got HI!"
End Select
This is saying, If the packet says 'HI' then log it on the server (That's why we sent data from flash saying HI)
That's all for this tutorial, It was very very very basic, But hopefully you get some sorta idea.
Note: I will be writing another tutorial explaing on how to receive data and such like, This is just a stepping stone.
Written by: Damien
This tutorial will be teaching you how to connect to a server and send data. For this tutorial we will be using mikeys multiuser server which can be downloaded here : http://www.mmoccforum.com/server-sid...html#post57041
Please note the link above is the server's source code, So you need VB6 installed to view it.
This is assuming your using Flash MX, I have not used XMLSockets in any other versions of Flash, So i don't know if they vary.
This tutorial isn't going to be to indepth, Cos im quite tired :p
First off, Open Flash.
Write some text on the canvas making sure it's static.
Then convert that into a button symbol (Opposite click and select 'Convert to symbol' then select button from the list)
Click the button once, Then goto the actions panel and put the following (I will explain the code after):
on (release) {
socket = new XMLSocket();
socket.connect("[redacted-ip]", "2300");
socket.onConnect = function(success) {
if (success) {
socket.send("HI");
}
};
}
Let's take the code apart:
on (release) {
}
This is telling us when a user releases the mouse from clicking the button, That we're going to preform the code that's inside.
socket = new XMLSocket();
This is creating a new socket called 'socket'
socket.connect("[redacted-ip]", "2300");
This is telling out socket to connect to ip address [redacted-ip] and port 2300 (Because the server is listening on port 2300 for incoming connections, and the server is being ran localhost ([redacted-ip]) )
socket.onConnect = function(success) {
};
This is telling us, When connected to the server perform the code that is inside. The 'success' will either return true (if it connected) or false (if it failed to connect)
if (success) {
socket.send("HI");
}
This code is saying if success equals true then send a packet saying 'HI'
Now if you go into the VB server and click 'ModProtocol' you'll see this:
Case "HI"
frmMain.logit "Got HI!"
End Select
This is saying, If the packet says 'HI' then log it on the server (That's why we sent data from flash saying HI)
That's all for this tutorial, It was very very very basic, But hopefully you get some sorta idea.
Note: I will be writing another tutorial explaing on how to receive data and such like, This is just a stepping stone.
Written by: Damien
Very helpful although Flash hasn't really appealed to me +Rep .
If you wanna add more to the protocol then simply do:
Code:
If you wanna add more to the protocol then simply do:
Code:
Nice tutorial thats one of the very few that give it to us simple and V clear +REP if i can
Quote:
Quote:
Well, I will TRY and get them done today at some point. If not, Then the next time im free xD
Very nice tutorial Damien ! +Rep.
Flash seems quite easy, usually sockets are one of the hardest things in a language and that is very simple.
I'll give you rep once i spread it around
I'll give you rep once i spread it around
Yeah flash sockets are really easy...Easier than VB i'd say, And thanks :p There's just a few things about using XMLSockets , Which i'll explain in the next tut.
Just a quick post. You can also use XMLSockets in Lingo too. I used to use them before i learnt how the Multiuser Xtra worked. A quick example:
Code:
Code:
Recovered from /coding-tutorials/6363-basic-xmlsocket-tutorial-2.html · captured 2008.