Unlimited Plugins, WordPress themes, videos & courses! Unlimited asset downloads! From $16.50/m
  1. Code
  2. Games

Create a Microphone-Controlled Flash Game: Code


In this mini-series, we're creating a spaceship game where the main control is via the microphone: shout louder to make the ship fly higher. So far, we've created all the required graphical elements for the game. Now, it's time to work on our code. We've got a lot to do, so let's get started!

Final Result Preview

For the purposes of keeping the tutorial simple, we have done no error checking for the existence of a microphone. This means that, if you do not have a microphone plugged in, turned on, and set up for use with Flash, the game won't work: you'll get an Error #1009. Check the comments in Player.as in the source files for information on how to deal with this.

A Small Note:

For some reason Flash Builder isn't working perfectly. In particular, it's ignoring code hinting - but, nevertheless, one should be able to follow the tutorial.

Project Setup

Creating the Player

Creating Space Objects

Player Animation and Collision Response

Setting Up Scores and Lives

Creating Our Background

Cleaning Up Our Game

Creating the Game Over Screen


Thank you for watching. It's been a huge tutorial, and afterwards I would have liked to do some things differently:

  • First off the classes have just been added one by one, but it would have made more sense for the classes to be organised in packages.
  • Even though our project works fine, we do get some run time errors, which isn't very neat.
  • Also, it's pretty easy to get very far by saying nothing, and just sticking to the bottom of the screen.

Nevertheless, I hope you enjoyed this tutorial, and most importantly learned something from it.

Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.