PDA

View Full Version : Basic Flash Game Tutorial.



Colin-Roberts
14-07-2008, 06:08 PM
For this I will be using flash 8. I'm assuming you have some knowledge of flash. This is not a copy and paste and get a fully working game kinda of tutorial...

First you will need a server to connect too.
Palabre
XML Socket Python Server
Freehttp://palabre.gavroche.net (http://palabre.gavroche.net/)

Mostrey
Flash / Python Socket Server
Free
http://mostrey.be (http://mostrey.be/)

Flash Now
Flash Socket Server
Free (5 User) $495 (Unlimited)
http://www.nowcentral.com (http://www.nowcentral.com/)

Electro Server
Flash/Lingo Socket Server
Free (25 Users) $700 - $4400 (500- 200 000 Users)
http://www.electro-server.com (http://www.electro-server.com/)

Smartfox
Flash Socket Server
Free (20 Users) $500 - $2000 (100-Unlimited)
http://www.smartfoxserver.com (http://www.smartfoxserver.com/)

Oregano
Flash Socket Server
Free
http://www.spicefactory.org/oregano/

Any of those servers will work nicely.

**Warning Each Servers Connection and Reply Codes Is Different. This is only a basic idea**

First you need to give the frame some actionscript so it can connect to the server.
To do that you would use something like this:


mySocket = new XMLSocket()
mySocket.connect("ip", port)
stop();

mySocket.onConnect = function(success)
{
if (success)
gotoandstop("Scene 1", 2)

}
Next you would need a login for your user's to login to your game obviously.
You need 2 fields. Call 1 username and the other password. Then you need a button for submit..

The the submit button would have a code to send to the server//


on (Press) {
mySocket.send("setname " + username + " " + password + " 0 0")
}
The server will reply with a code saying if it's valid or not and if the user has special privalages or not.

You need to tell the client what to do if the user is valid.
You would use something like this:


if (packets[0] == "auth_ok") {
gotoandstop("Scene 1", 3)
}This just goes to the frame with your chat in it if the user exists.

Next you will need a chat bar..
Make 1 input text field and another submit button.
set the var of the input text field as chat.

Then to send the chat to the server so everyone can see it. You would do something like this:

on (press) {
mySocket.send("speak " + chat)
chat = ""
}I'll add more later I'm have to work soon. Maybe I'll add pictures too if people want.

Want to hide these adverts? Register an account for free!