Sunday, 14 December 2008

Click game part 2

This Flash tutorial is a continuation of the clicking game tutorial. This time I will add addition features to the game. The final score will be displayed in a separate scene with an appropriate message. An optional restart button will also be included.

Before you attempt this tutorial be sure to have completed the previous part. I have used an Action script 2.0 file for this tutorial.

Clicking game part 2

Step 1

On the timeline right click on the 1st frame of the actions layer and select Actions. And add the additional code below, most of it should look familiar.

ball._visible = false;
total = 0;
hits = 0;
end = 20;
ball.btn.onPress = function() {
ball._visible = true;

seeBall = function () {
if (total < end){
ball._x = Math.random()*300;

ball._y = Math.random()*300;
ball._visible = true;
} else {
ball._visible = false;
gotoAndStop("Scene 2", 1);
doball = setInterval(seeBall, 800);

Step 2

Select shift + F2 to open up the scene panel. And click the little black plus sign to add a new scene. You should notice a new scene appear on the scene panel and the stage should now be blank.

Step 3

Now select the static text tool (T) and type your message on the stage. I type the following below, but you can type whatever you want.

And then select the dynamic text tool and drag a small box below your text. This dynamic text box will display your final score.

Step 4

Using the selection tool (V) select the dynamic text box on the stage. And in the properties at the bottom of the screen, type “hits” for the variable. This allows you to link the hits acquired from the game to the dynamic text box.

Step 5 - Restart button

Now create your restart button on the stage. If you don’t know how to create a button, checkout the basic buttons tutorial. I made a simple circle text button, but you can create whatever kind of button you wish.

Now convert your button into a symbol by pressing F8. Choose an appropriate name, check button and click ok.

Right click on your button and select Actions and enter the following code:

on (release){
gotoAndStop("Scene 1" ,1);


Step 6

Test your movie clip Ctrl + enter.

You should now have a clicking game. I have also included a custom cursor.


Edwino 20 January 2009 at 18:43  

nice game i love it

Hai 3 February 2009 at 09:13  

oh i love this game, but I want to do when I click the ball, it will burn or something like that before it becomes invisible. can you tell me how I do that ??? (sorry for my bad English :)

iliketo 3 February 2009 at 10:33  

@Hai you create a new keyframe inside the ball movieclip and add your desired effect there.

Mr. lazy boy 6 May 2009 at 00:25  

hei i can't seem to play this game after i followed tutorial 2.. but i could play when i finished tutorial part 1..
i now see the scene 2 keeps poping up only..

what am i supposed to do.. ??

iliketo 6 May 2009 at 02:40  

@Mr lazy boy

I think you need to put a "stop()" in scene 1.

yogi 2 June 2009 at 05:47  

hi where do i put "stop()" in scene 1

iliketo 2 June 2009 at 07:59  


The first frame on the timeline.

Anonymous 22 June 2009 at 13:08  

I got a final score of 53. Are you supposed to be able to click it multiple times each time the ball shows up?

iliketo 23 June 2009 at 04:06  


Yes, you can click as many times as you wish.

S3146158 7 October 2009 at 23:37  

could u please also explain on how to make the "start" menu in the beginning?

aniway, do u know how to transfer this game into as3 automatically? because i wangt to know the different between those 2 scriptings...

iliketo 8 October 2009 at 05:14  


Checkout the code for the Actionscript 3 version here

Anonymous 25 October 2009 at 16:08  

I too would like to know how to create the 'START' frame for this tutorial.


iliketo 6 November 2009 at 02:51  


You basically need to insert a new scene and place a stop() method in the timeline. Then create your button on the stage and add the gotoAndStop() method like below to your button.

on (release){
gotoAndStop("Scene 2" ,1);

Pedropan 28 November 2009 at 08:36  


I have followed the steps and after pt 1 the game wroked fine but after pt 2 when i press CTRL + ENTER the two screens flash up one after the other really fast over and over again. I have tried adding a stop() to the first one at the bottom of the actions but when i test it it just stops on that screen when the game has finished and doesn't go onto the "congratulations" page.

Please help!!

iliketo 28 November 2009 at 15:28  


You should add the stop() method before all the other Actionscript code. i.e at the top. And make sure when you insert a new scene, the name is called "Scene 2".

Jessica 20 January 2010 at 13:44  

Can you tell me why on the second time round the ball moves faster?

iliketo 20 January 2010 at 14:17  


It seems fine to me.

nico 20 February 2011 at 11:21  

Please, could you be more specific in this second part of the tutorial?

iliketo 25 February 2011 at 16:06  


What part are you having problems with?

  COPYRIGHT © 2014 · ILIKE2FLASH · Theme by Ourblogtemplates

Back to TOP