Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to create a browser game using actionscript/flash. Currently, I'm trying to understand how I would go about creating a back-end which interfaced with my MySQL database.

As far as I understand, If I create a php file on a webserver called test.php and then navigate to a webpage hosted on the server eg., the php script will run and display the result in my browser.

This would use http. Is this how communication between client and server usually works in a flash game? for example, if the game needed to query the db. Would actionscript have to essentially invoke the url of the php script that would execute the query? it could then parse the data and use it.

If this is the case, then is JSON considered a good way to transfer data over http?

share|improve this question
JSON through RESTful ( and just request it from Flash. Like with AJAX and JavaScript, but with Flash and ActionScript. And parse in Flash/AS. – joltmode Jul 10 '12 at 18:23
up vote 1 down vote accepted

There are two primary approaches. If your game's needs on the server infrequent (storing high scores, loading account info, etc.) then you can simply make HTTP calls from Flash to your PHP scripts. Flash can send variables to the script using standard means and then parse some output format you print from the PHP script (XML, JSON, whatever).

If your game requires more real-time or server-push data, like chat, multiplayer features, etc, ten you may want to use Flash's networking API, such as the Socket or XMLSocket classes. Interfacing these properly with a server is a bit more difficult; PHP is not at all an ideal language to use for such things due to its HTTP-oriented internals (it is designed to run for short scripts servicing a single request, not long-running event- driven multiplexed IO server processes). At risk of sounding like a brogrammer, you might want to give NodeJS a look, particularly the popular socket library

If you're unsure which you want, you probably want the first one. It is much easier to deal with and is likely closer to your skill level. Move on to the more advanced networking approach only if you really need it, and only after you have a solid understanding of the simpler model.

share|improve this answer
I definitely want the first one. Thanks for the answer – Tim Rogers Jul 11 '12 at 9:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.