Making Flash games the free way

At one stage, developing Flash games required an expensive licence, or piracy. Thankfully, the open source FlashDevelop, along with things like the Flex SDK from Adobe, has changed all that. I’ve been working on a project with TuDocs Studios which has benefited from the availability of FlashDevelop, but admittedly I hadn’t got my teeth into much coding. I decided I needed to learn ActionScript though (it’s been on my ‘todo’ list for years!), and it’s been more straightforward than I had expected.

Before going any further, it must be stressed that FlashDevelop is most certainly not a drop-in replacement for the full range of Flash-oriented tools you can get from Adobe. In fact, it really only offers you straight-up coding, so things like GUI-based keyframe animation are not available. It is solely aimed at programmers.

With that said, it’s got some great features. The code auto-completion is first-rate, even for your own code — it even helps you build properly-formatted documentation comments automatically. And after you get the environment setup the first time, it’s a dawdle to actually build and run SWF apps. Here’s a simple mini-game that was the culmination of my first day of proper tinkering:

Controls: Arrow keys.
Objective: Fly your ship to collect the coins, without bumping into the edges.

What’s in the app?

If you’re interested, the above app is comprised of the following primary classes:

  • Main — program entry point; switches between the menu and game as necessary
  • MainMenu — displays the main menu buttons (Easy, Medium, Hard, and “Woah…”), and triggers a callback in ‘Main’ when they are clicked
  • Button — a simple single-image button class; displays a hover effect, and triggers a callback in its parent when clicked
  • Game — the workhorse of the game mechanics and player input
  • Player — handles the physics/graphics of the player object
  • Collectable — handles the physics/graphics of the coin
  • KeyEventLogger — tracks synchronous key events to provide asynchronous querying (apparently async queries used to be in AS2)

At this stage, I’m not using a physics library at all — it’s all my own (slightly cludged) code, for whatever it’s worth. 🙂

Thoughts so far…

There are some quirks of AS3 that still catch me out a little bit, but by-and-large it is an effective language. It reminds me very much of working in C#. There are lots of helpful libraries to do everything from some basic math operations through to applying visual effects in your game. The events structure seems particularly useful, with the ability to pass callable functions around by name very easily. I’m also impressed by how easy it is to embed media directly in the SWF using just a couple of lines of code (although the code itself is a little bizarre to look at!).

There are lots of tutorials available online, so it’s worth having a quick search on Google if you’re interested in learning more. However, do bear in mind that many online tutorials will apply to the paid-for Flash tools, and not the free Flex SDK. Here are some useful starting points though:


Leave a Reply

Your email address will not be published. Required fields are marked *