Copy link to clipboard
Copied
Hi so I am going to make quite a big game/app in AS3 and I need someone to point me in the right direction, I know as3 and have programmed many games.
This game is going to include multiplayer and we are going to use smartFox to do this.
Now the area which I need some infomation on is the servers for holding the player details. (Etc. Level, Cash)
First off:
How would I set up a server? Do I use MySQL? Is it like a webpage which I can connect to with my game?
How would I connect to it via AS3? Would I have to use MySQL SELECT and MySQL Files to find the player then send back there details?
Basicly I need to know how games like FarmVile setup servers to hold player details because I have to do the same for this game.
It's really up to you how you get the data back to the game. When you use classes like URLLoader you can send variables (via GET or POST) to the server to authenticate and route your request. At that point your PHP script is responsible for reading the request and responding with the information however you like it.
For your first game I would recommend you stick with very well known structures like XML or JSON for responses from your PHP scripts.
For example, if you use JSON, you first set up y
...Copy link to clipboard
Copied
This is limitedly on topic for a Flash discussion. This really belongs in either Dreamweaver or Cold Fusion or some server side technology area.
That aside, if you plan on having a large scale game, you're going to need to step back and do quite a bit of learning and research for your needs.
Considering the best possible scenario, you're not doing this professionally for someone and quality is inconsequential, your first steps are first selecting a server-side language and database. You will be sending data directly from your game to a server. I'll go out on a limb and assume it'll be a small to mid size game, utilizing a web host who grants you permission to use their servers for your purpose.
Probably the most overwhelmingly rampant a-typical solution is PHP for scripting and MySQL for the database, for many reasons I won't get into. This means you'll need to learn both a server side language (like PHP), and entirely separately, a database and its query language (SQL). These are provided by just about any host out there.
For learning, development and sandboxing, I'd recommend installing a server locally. It's much easier to initially develop and debug. A simple free solution for a full web server, database and scripting language is WAMP (Windows Apache MySQL PHP) installer:
http://sourceforge.net/projects/wampserver/
Once you learn the scripting, then proper database setup and usage, your game will communicate directly with the web host. You can either pass game information from Flash directly through scripts (most likely for you) or in more advanced/optimized ways with services (most likely not for your first game). Depending on how you do it, the server will be your games model (responsible for all data).
So from here you should take a look at various server side languages and see which syntax you like best. You'll also need to learn actually what a database is and how to use it. Most server side languages come with a way of interfacing with databases so that'll just be a natural part of your learning of server side scripting anyhow.
You can read about PHP here:
and MySQL:
However for rapid training you may want to consider a video training site like Lynda:
Copy link to clipboard
Copied
Hey,
Thanks for the reply!
I know both MySql And PHP so it should not be to hard to execute PHP files from AS3 to retrive data from my server.
So am I right by thinking I need to buy webhosting which will hold my database which I can then comunicate with via my PHP scripts???
and also what hosting providers would you recomend?
My last question, So once I have retrieved the data from my database with my PHP script how would I then send it to be used in AS3? Would I need to use javascript?
Sorry about all the questions, I know the languages because I do web programming and game programming but I have never mixed them together to make a game like this so this is why I am unclear on how to approach this project.
Thanks for your time.
Copy link to clipboard
Copied
It's really up to you how you get the data back to the game. When you use classes like URLLoader you can send variables (via GET or POST) to the server to authenticate and route your request. At that point your PHP script is responsible for reading the request and responding with the information however you like it.
For your first game I would recommend you stick with very well known structures like XML or JSON for responses from your PHP scripts.
For example, if you use JSON, you first set up your request in AS3 telling it that you will receive plain text back (not binary or URL encoded variables). Your PHP script receives the request, performs the necessary operations (on the database, etc) to get the information you need. It is then responsible for structuring it back to what Flash is waiting for (JSON) and as you probably know PHP has JSON encoding built in (http://php.net/JSON). After you craft your response and print it out, AS3 will consider that a response. Then on the AS3 side you decode that JSON and use the information as needed.
Eventually in the future when your game scale gets larger you can start making web services that handle more efficient binary formats like AMF. While you can do it with standard POSTs it's not always even worth it performance wise. Also you'll go from HTTP requests to direct socket requests. If your game is of a standard type you may even use RESTful based web services so look into those if you're not familiar.
Yes, you'll need a host, however I can't recommend one because I have no idea what you're building. If you're planning on building a MMO then no web host is really going to give you an inexpensive cluster hosted account for that scale of a game. If it's just keeping track of leader boards and user accounts then I often use hosts that can scale from tiny/cheap to dedicated using my own hardware, like site5.com.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now