Wednesday, February 24, 2010

FLASH DIGITAL CLOCK


Alright so I'm going to help all you folks out there who have been dying to know how to make a digital clock in flash...get ready! Here are the easy steps!


1. In your timeline create 3 layers and name them actions, text and background. Similar
to what you see above...
2. Select frame 1 of your backgrounds layer and design the frame for
your digital clock.
3. Select frame 2 of your backgrounds layer and press F5.
4. Now go to frame 1 of your text layer and insert a dynamic text field
in your work area.
5. Select frame 2 of your text layer and press F5.
{To insert a Dynamic text field}
Select text tool from your tool box, Select Dynamic text from Text pop-up menu in the Property inspector. Click on your work area wherever you want the digital clock to appear.

6. Name this Dynamic text field instance as "clock_txt".
7. Go to frame 1 of actions layer. Copy and paste the script below into the action window.

time=new Date(); // time object
var seconds = time.getSeconds()
var minutes = time.getMinutes()
var hours = time.getHours()
if (hours<12)>
ampm = "AM";
}
else{
ampm = "PM";
}
while(hours >12){
hours = hours - 12;
}
if(hours<10)
{
hours = "0" + hours;
}
if(minutes<10)
{
minutes = "0" + minutes;
}
if(seconds<10)
{
seconds = "0" + seconds;
}
clock_txt.text = hours + ":" + minutes + ":" + seconds +" "+ ampm;

8. Now go to frame 2 of the actions layer and press F6 to insert a new keyframe.
Still keeping the play head on the frame 2, go to action window and copy paste the script below...

gotoAndPlay(1);

9. Yaay! you're clock is now ready. Go ahead and press ctrl + enter
view your clock!


1 comment: