Join The Community

Search

June 02, 2010

Making Date Countdown in Flash

The Result

Now, I will teach you How To Making Date Countdown in Flash. It’s very simple tutorial, you can change the Years, Month and Dates in the script code. In this tutorial, we must use Actionscript 3.0. So, follow step by step to got the best result and watch the Videos.

See The Videos!

1. Open Adobe Flash.

2. Choose Actionscript 3.0.

Actionscript 3.0

3. In the Properties panel or right click choose Document Properties, change the Width 300 px and Height 200 px.

Properties

Document Settings

4. Click File > Import > Import to Library. Choose the images as background.

 Import to Stage

Import Image to Library

5. When showing “Import Fireworks Document”, click OK.

Import Fireworks Document

6. In the Library panel, drag the Images to the stages.

Library panel

Blank Stage

Import Stage

7. In the Timeline panel, change the name of Layer 1 to “Background”. And click Lock icon to Lock the background.

Lock Background

Background layer

8. Click New Layer icon in the bottom of Timeline panel.

New Layer

9. Change the name “TextField”.

TextField layer

10. Click Text Tool in the Tool Box.

Text Tool

11. In the Character panel, choose the Font “_sans”, and size “20 pt”.

Character panel

12. Create 2 Text Box in the stage.

Text Box

13. On the Properties panel, give the name “date_txt”. Choose “Classic Text” and Choose text as “Dynamic Text”.

Properties panel

14. On the first Text Box, give the name “date text”.

Date Text

15. Click the second Text Box, on the Properties panel, give the name “countdown_txt”. And don’t forget choose Text as “Classic Text” and “Dynamic Text”.

Properties panel

And still on the second text, give the name “countdown text”.

Countdown text

16. Click New Layer icon in the bottom of Timeline panel and give the name “Actionscript”.

New Layer

Actionscript panel

17. Still in the Actionscript layer, right click, choose Action.

Action

18. When opened, give this script.

Action Frame panel

// USER CONFIG SETTINGS
var countdownYear:Number = 2012; // 20xx
var countdownMonth:Number = 1; // 1-12
var countdownDay:Number = 23; // 1-31
date_txt.text = countdownMonth+"/"+countdownDay+"/"+countdownYear;  // date formatting
// USER CONFIG SETTINGS // EVENTS AND TIME CALCULATIONS
var static_date:Date = new Date(countdownYear, countdownMonth-1, countdownDay, 0, 0, 0, 0);
addEventListener(Event.ENTER_FRAME, fl_updateCountdown);
function fl_updateCountdown(evt:Event):void
{
    var now_date:Date = new Date();
    var nowCountdown:Number = static_date.time - now_date.time;
    var dayTill = ((((nowCountdown/1000)/60)/60)/24);
    var hoursTill = (((((nowCountdown/1000)/60)/60)/24) - Math.floor(dayTill))*24;
    var minTill = ((((((nowCountdown/1000)/60)/60)/24) - Math.floor(dayTill))*24 - Math.floor(hoursTill))*60;
    var secTill = (((((((nowCountdown/1000)/60)/60)/24) - Math.floor(dayTill))*24 - Math.floor(hoursTill))*60 - Math.floor(minTill))*60;     countdown_txt.text = Math.floor(dayTill)+"days "+Math.floor(hoursTill)+"hrs "+Math.floor(minTill)+"min "+Math.floor(secTill)+"sec";
}
// END


19. To test the movie, click Control > Test Movie or press CTRL + Enter.

Test Movie

20. And this is the result.

The Result

REMEMBER!: In the Action – Panel, you can change the Year, Month, and Date. See the picture below!

User Config Settings


Share to Facebook Share to Twitter Share to MySpace Stumble It Share to Reddit Share to Delicious More...

0 comments:

Post a Comment