KOTAK HITAM : The Blackbox of Nothingman
  Monday, September 6, 2010
Linux Corner
Login
Username

Password



Not a member?
Sign Up Here!

Lost Password?
Menu
Users Online
 Guests Online: 1
 Members Online: 0

Total Members: 80
Newest Member: Supitra
Last Seen Member
pakdhetimin 6 days

IP Address : 66.96.249.197
Web Browser : Other
Powered by
Kios Domain
CO.CC:Free Domain

DONATION
Help us to develop opensource cms for everyone.
Donate us through Paypal :


Stats n Rank

Countdown Timer with Flash Actionscript 2.0

In this Flash tutorial you will learn how to create a countdown timer in Actionscript 2.0. Countdown timers can be used in multimedia applications, games etc. For example, a countdown timer can be used to simulate a rocket countdown or a countdown timer in game. The end results of the countdown timer will show numbered values decrementing every second. Here we will be using it to count down to 0 then the warning about time's up will play.

Here are the steps :

Step 1

Create a new Flash document and set the Stage Dimensions to 300x300 by clicking on the Size button in the Properties panel.
CountdownTimer1.jpg


Select the Text tool with static text and type your message on the stage. I have typed the message 'CountDown', but you can type whatever message you wish.

Step 2

Select the Text tool with dynamic text and drag a small box shape like below:
CountdownTimer2.jpg

and change the following:
Text Type: Dynamic
Instance Name: "timer"
Variable: "timer"
Line Type: Single
Selectable: NO

Step 3

Deselect everything (Shortcut: Ctrl+Shft+A) and open up the Actions panel (Shortcut: F9) or on the timeline right click on the first frame of layer 1 and select 'Actions' and enter the following lines of code in the Actions panel:
stop();

_root.timer = 60;
clearInterval(id);
id = setInterval(function () {
_root.timer -=1
}, 1000);

CountdownTimer3.jpg

**The current count is 60 seconds, but you can change it to whatever you wish. This code contains the cleartInterval() method which stops the function call. And also contains the setInterval() method which calls the time in milliseconds.

Step 4

Test your countdown timer Ctrl + enter. You should now see a countdown from 60 seconds.

Step 5

So the timer counts down, but what happens when it hits zero? -1...-2...-3... Not very helpful! Now you can make anything happen when the timer hits zero, but we're going to make it go to the next frame. So create a blank keyframe after the one you are working on. Put what you want on the frame, I'm going to write a piece of text warning about the time is up. Remember to delete the timer if you created a normal Keyframe.
CountdownTimer4.jpg


Step 6

Select the Text tool with static text and type your message on the stage of frame 2. I have typed the message 'TIME'S UP!', but you can type whatever message you wish. Deselect anything and click on frame 2 and on the actionscript add stop(); to the frame to ensure that it stops on the next frame if you want it to. Now go back to the first frame and create a new Symbol (Shortcut: Ctrl:F8), select MovieClip. Use the Rectangle Tool (Shortcut: R) to draw a small square. The design of this does not really matter because it will later be hidden off stage.
CountdownTimer4a.jpg

CountdownTimer4b.jpg

CountdownTimer5.jpg


Step 7


Hit the small blue arrow underneath the timeline to the left to return to the main timeline. Open up your Library (Shortcut: Ctrl+L), locate the square and drag it onto the stage. Then select the square, open up the Actions panel and paste the following code:
onClipEvent(enterFrame){
if(_root.timer <= 0){
_root.gotoAndPlay(2);
}
}

Explanation:
if(_root.timer <=0) - if the timer is less than or equal to 0
_root.gotoAndPlay(2); - the main timeline should go to the 2nd frame
CountdownTimer6.jpg


If you wish you can drag the square off the stage so it does not appear when you publish the movie. Hit Ctrl+Enter to test the movie. When the timer hits zero, it will display the 2nd frame.
Comments
No Comments have been Posted.
Post Comment
Name:

Validation Code:

Latest ArticlesMost Read Articles
Eyangku Pejuang Tangguh
Hachiko: A Dog Story
Tips jika kena Tilang Polisi
Countdown Timer with Flash A...
Advanced PHP Script URL Redi...
Tutorial Hacking
Geronimo
Installing Windows XP on Com...
Meta Tags Explained
Download Video dari YouTube
Latest UploadsPopular Downloads
Themes Merah Putih v7 -dl: 55 times
Extended Online User Panel v... -dl: 48 times
Most Read Articles Panel v7 -dl: 49 times
Similitude White Theme -dl: 51 times
Weather Panel v6 -dl: 56 times
Virus Threats Panel v6 -dl: 47 times
Center Lower Panel v7 -dl: 47 times
Darken Theme KotakHitam -dl: 58 times
Similtude Black Theme -dl: 52 times
Sex Education -dl: 23 times
Indonesian Language Pack v7 -dl: 69 times
Darken Theme KotakHitam -dl: 58 times
Weather Panel v6 -dl: 56 times
Themes Merah Putih v7 -dl: 55 times
Similtude Black Theme -dl: 52 times
Similitude White Theme -dl: 51 times
PHP Editor -dl: 50 times
Most Read Articles Panel v7 -dl: 49 times
Extended Online User Panel v... -dl: 48 times
Virus Threats Panel v6 -dl: 47 times