Posted tagged ‘counter’

Click Counter and 1time…. 2times script

August 3, 2008

Hello. In this tutorial, we will make something as simple as a click counter. Yes, what it does is to count how many times you’ve clicked the mouse. It will also check that there’s no grammatical errors such as 1 timeS.

What we will be making


Make a new MC and put it off stage. You should also add a static text field (on the stage) with the text: “You’ve clicked the mouse:”. Then to finish this step, add two dynamic text fields, one should have the variable “clicks”. The other one should have the variable “textbox”. When you’re finished with that, go on to the next step.


Now to some script, in this step, we’ll explain TWO WHOLE LINES OF CODE!! This code should be put on the frame:

clicks=0;//mouse clicks
textbox="times";//This will fix grammatical errors like 1 timeS

So, study the code too, so you know what it is for!


Now, this is the final step, where you should add code to the MC which should be off stage. The code is shown and explained below:

onClipEvent(mouseDown){//When you click
_root.clicks++; //The number will go up
//fix grammar errors
if(_root.clicks===1){//If the amount of clicks is one
_root.textbox="time"; //Then it should be time
}else{ //But if not....
_root.textbox="times"; //It should be times