Click Counter and 1time…. 2times script


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

STEP 1:

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.

STEP 2:

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!

STEP 3:

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
}
}

Advertisements
Explore posts in the same categories: ActionScript 2.0, Basic

Tags: , , , ,

You can comment below, or link to this permanent URL from your own site.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: