subject: Understanding Flash Game Development In An Easy Manner [print this page] In case you are interested in casual mobile applications or Flash game development but are new to Actionscript, don't worry, this text piece will be a real help. Here is described the simple use of code snippets panel (present in Adobe Flash Professional CS5.5) for creating Jewelry Heist (a popular mobile game). The Flash game development demonstration will help you in applying as well as modifying device-specific and common interactive code snippets for incorporating multiple features in the game.
The Code Snippets panel includes ActionScript 3 snippets, which are usually used in a variety of Flash projects such as games and banner advertisements. Before going further, it is vital for a Flash game developer to get acquainted with the Code Snippets panel as well as the prebuilt code so that it becomes easy for him/her to add them to the projects.
This Flash game development tutorial features the following code snippets:
Touch and Drag Event
Mouse Over Event
Countdown Timer
Stop At This Frame
Click To Go To Frame And Stop
Jewelry Heist is a game where a player needs to steal gemstones placed in a museum. The stealing has to be done without getting touched by the laser beams, which are in continuous motion.
Displaying instructions
To begin with, a Flash game developer needs to download JewelryHeist files and save it as JewelryHeist.fla extension. Open the file on Flash Professional. A thorough examination of main Timeline will help you to understand the construction of the finished project. FLA document of the game contains three frames. In the first frame you will find the game's instructions, in the second frame you will find the game's graphics and play logic, and in the third frame you will find the Game Over screen. It is must to add code to frame 1.
Handling Frame 1
A code needs to be inserted for pausing the play head at frame 1.
Locate and open the file named Frame1.fla. There is presently no code in this document
Click Frame 1 for positioning the playhead on Frame 1
Code snippets panel can be opened by choosing Window > Code Snippets
Move to in the Timeline Navigation category and double-click the Stop at This Frame snippet. The Actions panel will get opened to show the addition of Stop(); command
Adding code to Frame 2
Locate and open the file named Frame1.fla
Click Frame 2 in the Timeline, in the Action Layer
Select Gem 1 movie clip symbol, which is orange
Choose Window > Code Snippets to open the Code Snippets panel
Double click the option Touch and Drag Event Snippet
Repeat the above given steps for Gem 2 as well as Gem 3
Save and leave file
Updating laser beams while using Mouse over event snippet
Click on Frame 2
Select the Laser1Animation1 movie clip symbol
Choose Window > Code Snippets to open the Code Snippets panel
Go to Event handlers category and double click on Mouse over event snippet
Repeat above steps for Laser2Animation2 as well as the Laser3Animation3 movie clip symbols
Read all instructions and panel carefully
// Start your custom code
// This example code displays the words "Moused over" in the Output panel.
trace("Moused over");
// End your custom code
Defining the countdown timer snippets duration
To set playheads location, click Frame 2 of the Action Layers
Edit Actionscript in order to replace below given line:
var fl_SecondsToCountDown:Number = 10;
with this line:
var fl_SecondsToCountDown:Number = 1;
Again edit the code and replace below given lines:
trace(fl_SecondsToCountDown + " seconds");
fl_SecondsToCountDown--;
with this line:
gotoAndStop(3);
4. Save and close the file.
How to display Game over Screen
Locate and open the file named Frame1.fla.
To set playheads location, click Frame 3 of the Action Layers
Select Play Again on the Stage movie symbol.
Double-click the Click to Go to Frame and Stop code snippet.
Locate and Edit the below given line
gotoAndStop (5);
to this:
gotoAndStop (2);
Optimizing the final game
Locate and open the newly craeted Frame3.fla.
Place the playhead on Frame 3 by clicking Frame 3
Choose Window > Actions to open
Use following code at line 1
fl_CountDownTimerInstance.reset();
Update Quit Button
Set the playheads location by clicking Frame3 of Action layer
Select the movie clip symbol named Quit on the Stage
open, choose Window > Actions to open it. Write the following code at the bottom of the Script window: