Learn how to use Adobe Flash with all the free tutorials. Game Making, Animating, Cartoon Design, Web Design and much more...
How to make a time limit
Making a Countdown Timer
This tutorial is only a short and simple one.
Start by naming layer 1 counter, insert another layer and name it actions. Right click on frame 1 and select actions. On the first line type in:
Stop();
We need to do this as we will have 2 frame and we want it to stop on frame 1 as this is where a countdown will be.
On the first frame of the counter layer draw out a basic shape with a fill colour (recommended). This is going to hold the countdown time. Select the whole shape you just made and convert it to a Movie Clip, name it time control. The reason we will be naming it time control is we are going to use this to control the countdown.
Select the text tool and same as before make sure it is set to dynamic text, now change the font colour to a different colour to what the time control is, otherwise you won’t be able to see the countdown.
Now draw out the text box on top of the time control movie clip.
Give the countdown a var of countdown, var was discussed in a previous tutorial.
Now double click on the time control movie clip to enter its timeline.
Here is where we will set the speed of the countdown. First of all, check to see what your fps is set to, it is set to 12 by default, so I will use twelve. The fps was discussed in a previous tutorial. Now I want my countdown to go down a number every second, so I am going to insert a keyframe at frame 13. I realize I said 13 and not twelve. Why I did this: If you look at the bar underneath the timeline where it displays how many seconds into the timeline you are, you’ll see that at the 12th frame it is .9 sec, and at the 13th frame it is exactly 1 second.
Now right click on the 13th frame which is the last keyframe, and select actions.
Now on the first line type:
_root.counter -= 1;
This simply means that every time this frame is played the countdown will go down by one. The reason we have put _root because we are referring to the timeline.
Note: Before the = sign there is a minus “-“ you cannot see it very well.
Now click on scene 1 to enter the main timeline.
Right click on the first frame in the action layer, and select action, underneath stop(); type in:
var counter = 10;
This sets the counter to start at ten.
Now right click on the time control and select actions, on the first line type in:
onClipEvent (enterFrame) {
if (_root.counter == 0) {
_root.gotoAndStop(2);
}
}
The reason we have put clip event is because we have applied these actions to a movie clip.
enterFrame means when the frame is entered, so you won’t have to press any buttons, it will just happens when the countdown reaches zero.
if (_root.counter == 0) {
_root.gotoAndStop(2);
}
}
This simply means when the counter reaches zero, it is to go to frame 2 and stop at frame 2.
Now close the actions menu. Insert a keyframe at the second keyframe of the counter layer, on the second keyframe, delete everything.
Now using the brush tool or the text tool write something like time up.
Now test the movie, the countdown will start running from 10 down to 0, when it reaches zero it will say time up.
Don’t worry is this tutorial was a little confusing, it will all come with time until you understand what all this AS2 means. We will be working with it a fair bit in later tutorials.
Before moving on to the next tutorial, have a play around in flash, creating some flash animations, testing out the simple AS2 we have recently learnt, think of this as revision, but have fun with this.
Tip 8. Have fun when using flash.
Why this helps: It is obvious, if you are creating things in flash that you find boring you lose interest, so if you are working on something in flash that is getting boring, try think of something you could add to this to make it fun.
Tip 9. Muck around in flash often exploring new things.
Why this helps: This is how we find out new things, improve our flash projects, get better at using flash.
Alright, let’s start our next tutorial.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment