Digital Clock

13.1.2006, 18:50
Submited in: Flash | Total Views: 65236

In this tutorial I will show you how to create  digital clock with date in flash, using the action script.


Step 1

Open Flash and in Propertis Pannel (Ctrl+F3) click on the size icon (Ctrl+J), and set Width to 290 px, and Height to 60 px.

Step 2

Open again Properties Pannel and setup Static text, take Text Tool (T), and somewhere on stage type TIME, and under TIME title type DATE. Look at the picture.

Step 3

After that in Properties Pannel set the Dynamic text, click on the Text Tool icon (T), and  using drag and drop technique create two "squares" for time and date. Look at the picture!

Step 4

Select that empty "squares" for time and date, press F8 (Convert to symbol), and under Behavior (type -flash8)  choose Movie Clip, name whatever you like and press ok!

Step 5

Double click on a new made MC (empty square for time and date) to go in it's inside. After that click once on "square" for time, open Properties Pannel (Ctrl+F3) and under var type Hourtime. Click after that on "square" for date and in Properties Pannel under var type date.

Step 6

Go back on main scene (Scene1), select that MC (squares for time and date), open Action Script Pannel (F9), and paste this script:
onClipEvent (load) {
 days = new Array('Sunday','Monday','Tuesday','Wednesday','thursday','Friday',
 months = new Array('January','February','march','April','May',
 timedate = new Date();
onClipEvent (enterFrame) {
 hour = timedate.getHours();
 minutes = timedate.getMinutes();
 seconds = timedate.getSeconds();
 todaydate = timedate.getDate();
 day = timedate.getDay();
 dayname = days[day];
 month = timedate.getMonth();
 monthname = months[month];
 year = timedate.getFullYear();
 if (Length(minutes)==1) {
  minutes = "0" + minutes;
 if (Length(seconds)==1) {
  seconds = "0" + seconds;
 Hourtime = hour + ":" + minutes + ":" + seconds;
 date = dayname + " " + todaydate + " " + monthname + " " + year;
    delete timedate;
 timedate = new Date();

we're done!
Download example (23 KB)

Are you a website owner?
Click here to register and submit your tutorials!

Browse by category

Most popular tutorials