Home / Tutorials / Flash / Digital Date and Clock in Flash

Digital Date and Clock in Flash

Here I’m going to tell you how to make Digital Clock in Flash, it will also be having the Date. It looks simple in Flash but we have to give some Conditions and make it according to our desire. Hopefully you will like it.

You can also visit Smooth Analog Clock to make Analog Clock in Flash.

[DOWNLOAD SOURCE FLA FROM HERE]

1. First of all Take a new file in Flash. Don’t worry about the size, just take according to your desire. I’m here taking 500×200 px with 12 FPS.

2. You can use any picture for background. I’ve prepared this kind of background:

Now if you want to show date and time in single line then you will need only 1 Dynamic text and if you want to show date and time in separate lines then you have to take different Dynamic Text. As I’m going to show date and time in 3 lines then I’m going to take 3 different Dynamic Text. Just pick Text tool and before writing anything goto Property Panel and select Dynamic instead of Static. Now click anywhere in the file. Don’t write anything in it, just change the size. Likewise put other two also.

3. Now select each text one by one and give it Variable Name. For this goto Property Panel and there will be OPTION portion, here you will find Variable box, write there any name:

I’ve given First text name as ‘dayname’, second text as ‘fulldate’ and third text as ‘fulltime’. Try to avoid giving reserved name like time, date etc. So that is why I’ve used word full alongwith date and time.

5. After putting all text and objects, just press F5 key once to take another Frame, because for changing time it need another frame so that it should have a small animation.

6. Now actual part is going to start here, we are now going to give ActionScript. I’m trying to use simple actionscript so that it will be helpful for new Flash users.

Click on First frame and Press F9 to show ActionScript panel, here write the following:

// Actionscript starts here:

// current date and time will be stored in stunning variable
stunning= new Date();
//this variable will be to get Day Name
a=stunning.getDay();
// this varialbe will be to get Date
b=stunning.getDate();
// this variable will be to get Month
c=stunning.getMonth();
// this varialbe will be to get Full Year i.e. 2010
d=stunning.getFullYear();
// this variable will be to get Hours
e=stunning.getHours();
// this variable will be to get Minutes
f=stunning.getMinutes();
// this variable will be to get Seconds.
g=stunning.getSeconds();

// if Date will be in single figure, then it will add 0 on its left
if (b<=9){
b=”0″+b;
}
// if we show contents of variable a (which is used for Day Name) it will show day number, like 0 for Sunday, 1 for Monday and so on, but we want to show Day Name here so we are going to give Day Name to variable.
if (a==0){
a=”Sunday”;
}
if (a==1){
a=”Monday”;
}
if (a==2){
a=”Tuesday”;
}
if (a==3){
a=”Wednesday”;
}
if (a==4){
a=”Thursday”;
}
if (a==5){
a=”Friday”;
}
if (a==6){
a=”Saturday”;
}
// likewise if we show contents of varaible c (in which we called Name of Month) then it will also show numbers like 0 for January, 1 for February and so on, so here we are putting Names of month in variable.
if (c==0){
c=”January”;
}
if (c==1){
c=”February”;
}
if (c==2){
c=”March”;
}
if (c==3){
c=”April”;
}
if (c==4){
c=”May”;
}
if (c==5){
c=”June”;
}
if (c==6){
c=”July”;
}
if (c==7){
c=”August”;
}
if (c==8){
c=”September”;
}
if (c==9){
c=”October”;
}
if (c==10){
c=”November”;
}
if (c==11){
c=”December”;
}
// If Hour is in single figure then it will add 0 on its left
if (e<=9){
e=”0″+e;
}
// If Minute is in single figure then it will add 0 on its left
if (f<=9){
f=”0″+f;
}
// If Second is in single figure then it will add 0 on its left
if (g<=9){
g=”0″+g;
}
// We are going to show these variables in Text boxes

dayname=a;
fulldate=c+” “+b+”, “+d;
fulltime=e+” : “+f+” : “+g;

//Actionscript Ends here

7. Here you will get Final Digital Clock and Date.

[DOWNLOAD SOURCE FLA FROM HERE]

You can also visit Smooth Analog Clock to make Analog Clock in Flash.

About Wijdan Rohail

A professional Web/Graphic Designer, working as Freelancer since 2000. Designing is my passion, blogging is my hobby.

Check Also

Cold Blooded Text Effect in Photoshop - Thumbnail

Cold Blooded Text Effect in Photoshop

A Bit Scary, today we are going to work on Photoshop Tutorial about Text Effect. …

22 comments

  1. Error code 1093,Syntax Error
    and the error code found at these lines
    22.26.29.32.35.38.41.44.48.51.54.57.60.63.66.69.72.75.78.81.85.89.93.98.99

    Or give me your email,so i can attach the pic..thanks before

  2. Adobe Flash CS3 Pro

    • File made in Adobe Flash CS4, so that is why it is having unexpected file format error while opening. As for as code are concerned it should not be having any error. Try to use e=”0″ add e; instead of e=”0″+e; likewise. Or can you send us the Error you are getting while clicking on “Check mark” button?

  3. I’m following each step here, but it doesn’t work…i was paste the script at my file and i push the check mark button and appear many error messages, i try to paste the fla source and appear “unexpected file format”, please help me…

  4. thanks…very nice.

  5. Thank very much you Mate. You are a smart dude. I’ll do that during the week-end. Another question if you do not mind. What is the best way to learn actionscript ? As3 ?

  6. Sorry, my fault. I was talking about the analog clock you made some where else.

  7. I wonder where are the needles in Digital Clock please 🙂

  8. How did you make the shadows of the needles move so realistically ? Can you explain ?

  9. this is really nice and cool
    thanks 4 this tutorial
    do u know how to make battery indicator with % sign for mobiles in flash
    if yes plse mail me

  10. Hi, Only wimps use tape backup: _real_ men just upload their important stuff on ftp, and let the rest of the world mirror it. — Linus Torvalds

  11. Kunde glaub dem Makler nicht, ganz egal, was er verspricht. – Andre Kostolany

  12. Alhamdulillah, saya berhasil membuat jam digital maupun analog….

  13. What a good thing Adam had – when he said a good thing, he knew nobody had said it before.

  14. please include fla file,thats help us more

  15. this is really nice and I will certainly try to do this, looks bit tough but will try it.

Leave a Reply

Your email address will not be published. Required fields are marked *