A Step-By-Step Guideline On Creating A Simple iPhone Game Using Flash CS5.5

Ever since its inception in the year 1982, Adobe Systems has been busy serving its customers with absolutely remarkable softwares that have proved befitting both for the web designers as well as developers. Adobe Flash CS5 is the recent software that has been released by the company for individuals who’re inclined on compiling flash games and applications for a wide range of devices including iPhones, iPads and iPods. If you too are interested in developing a simple yet highly-appealing iPhone game using the all-new Flash CS5.5 software version then check out this blog where I bring to you a complete guideline on the same.

A brief on Adobe Flash CS5


Adobe Flash CS5(Creative Suite) comes as a comprehensive set of tools that are fit for creating movies, animations and games for the iPhone consumers. These tools have recently been re-designed for boosting the work flow of designers and developers who’re engaged in building gaming applications for the iPhone users. Initially, when Flash CS5 was introduced, it didn’t serve as a great tool for building even the simplest iPhone games. But, as time passed, Adobe came up with the release of CS5.5 that has made iPhone game development using Flash as easy as a mere walk in the park. In addition to serving as an excellent software kit for developing mind-blowing games, Flash also offers an additional benefit of exporting the game/app to the web, without the need for making any changes to the main source code.

What’s in this post?

In this post, you’ll get to know about the process of creating an iPhone game using the Adobe Flash CS5.5 toolkit. I’ll be developing the game of air hockey wherein the player will have to choose a hockey paddle and use it for flicking the puck around the board to hit targets and gain scores. The best part of step-wise process mentioned in this blog is that it can be easily followed by anyone who isn’t having any prior experience in using Adobe Flash or the Actionscript.

So, let’s get started with the steps

Step 1-Download and install a copy of Adobe Flash CS5.5 into your computer system.

Step 2– Now, create a new document in Flash. You can do this selecting File-> New and setting the type to “Air for iOS” followed by setting the value for framerate to 60 frames per second)fps). Also, don’t forget to set the document size to 640×960 for targeting retina display for older models of the iPhone.

Step 3- Now, create a graphic for the paddle used in the game of air-hockey. For this. Click on Insert-> New Symbol. Here, you’ll be required to name the symbol. In this blog, I’ve named the symbol as “HockeyPaddle”. Finally, click on ‘Advanced” to define what this symbol will be referred to in the Actionscript code.

Step 4– As per the fourth step, you’ll be required to draw the object. For this, simply tap the “O” key and create a medium sized circles that’s about 80 pixels in diameter.

Step 5– Build the Document Class. For this, go to File/New and select “Actionscript 3.0 Class” and name the class as “HockeyMain”, followed by saving it. Replace the contents of the HockeyMain.as file with the following:


package  {

import flash.display.Sprite;

public class HockeyMain extends Sprite {

var hockeyPaddle:Sprite;

public function HockeyMain() {

hockeyPaddle = new HockeyPaddle() as Sprite;





In the above code, :Sprite is added to the variable to enable the compiler to know that it needs to be of type Sprite.

Step 6– Now, save the flash project as Hockey.fla and hit the ‘Command’ and ‘Enter’ keys.

Step 7– Now, add the following code to make the hockey paddle follow the player’s touch/mouse:

package  {

import flash.display.Sprite;

import flash.events.MouseEvent;

public class HockeyMain extends Sprite {

var hockeyPaddle:Sprite;

public function HockeyMain() {

hockeyPaddle = new HockeyPaddle() as Sprite;


hockeyPaddle.mouseEnabled = false;

stage.addEventListener(MouseEvent.MOUSE_DOWN, handleMouseDown, false, 0, true);


private function handleMouseDown(e:MouseEvent){

hockeyPaddle.x = e.target.mouseX;

hockeyPaddle.y = e.target.mouseY;

stage.addEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove, false, 0, true);

stage.addEventListener(MouseEvent.MOUSE_UP, handleMouseUp, false, 0, true);

–—————————————–for more, please refer Google.


Step 8- Add the Hockey Puck

For this step, simply switch back to the HockeyMain.as file and add the below mentioned hockeyPaddle initialization code to the constructor:

hockeyPaddle.x = stage.stageWidth * 0.5;

hockeyPaddle.y = stage.stageHeight * 0.5;


hockeyPuck = new HockeyPuck() as Sprite;


hockeyPuck.mouseEnabled = false;

hockeyPuck.x = Math.random()*stage.stageWidth*0.6 + stage.stageWidth*0.2;

hockeyPuck.y = stage.stageHeight*0.3;

Also, declare a variable for the hockey punk in the class as explained below:

var hockeyPuck:Sprite;

Step 9- Make the hockey paddle and puck react to each other

So, with the hockey paddle and puck in place, its time to make the two react to each other. For this, you’ll need some variables for recording the last x, y coordinates of the hockey paddle. This detail would aid you in calculating the direction that the paddle is moving in. Add these variables:

var paddleLastX:Number;

var paddleLastY:Number;

After this, add these variables for recording the direction in which the puck is being hit:

var puckMomentumX:Number = 0;

var puckMomentumY:Number = 0;

Finally, add a function that would be called for checking the hit detection and implementing other game-related logic.

this.addEventListener(Event.ENTER_FRAME, update, false, 0, true); // add this to your constructor!

With that you’ll be done with the creation of a fabulous iPhone game.

Wrapping Up

Hope you’d have enjoyed playing around with Flash CS5.5 software. Today, the App Store is loaded with some amazingly rich Flash-developed games custom-made for gamers. So, what are you waiting for, go ahead and follow these steps for coming up with an outstanding iPhone game. Do drop in your feedback/comments/questions on this post, using the box provided right below this post

About Author: Emily Heming is an iPhone App Developer for Xicom Technologies .– a mobile application development service provider. You can also avail the option to hire professional mobile developers or programmers with her best assistance. For more information you can contact her.

Joe Granados the author

Joe Granados is the owner of WebDevTuts. He is also a web designer & developer who loves to design and develop websites. If you're looking for him you can find him via @webdevtuts

Leave a Reply