Customizable Analog Clock

Adobe Flash Tutorials :

Category: Adobe Flash Tutorials
Added: 04/03/2007
Views: 86,570

Customizable Flash Analog Clock

Tutorial Goal

Create a customizable analog clock in Adobe Flash. The time displayed depends on the viewers computer time. This tutorial will create the functionality of the Flash object below:

Step 1 : Document Setup

Open Adobe Flash and Modify the Document Properties.
Modify > Document
Size: 300 x 300

Step 2 : Create the Clock Face MovieClip

Select the Oval Tool, Oval Tool, and draw a circle of any size on the Stage.

Change the width and height of the circle to 190 using the Info Pane.
Window > Info

With the circle selected use the Align Pane to center it on Stage. Make sure the "To Stage" button is down, then click the two align options circled below:
Window > Align

Align Pane

Convert the circle on Stage to a MovieClip.
Modify > Convert to Symbol
Name: clock_mc
Registration point: centered

Convert to Symbol

Step 3 : Prepare Clock MovieClip for its Hands

Double click the clock_mc on Stage.

In the Timeline Pane, rename 'layer 1' to 'Clock Face'.
Create 3 new layers by clicking Insert Layer, Insert Layer, 3 times.
Rename each layer as below and Lock the 'Clock Face' layer by clicking the black dot in the Lock column. See below:

Prepare for clock hands

Step 4 : Create clock's second, minute and hour hands

Select the 'Second Hand' layer.
Select the Rectangle Tool, Rectangle Tool, and draw a second hand for your clock. You can easily customize the look later, for now a simple shape will do.

Second Hand Shape

With the shape selected use the Align Pane to center it on Stage. Make sure the "To Stage" button is down, then click the two align options circled below:
Window > Align

Align Pane

Convert the shape on Stage to a MovieClip.
Modify > Convert to Symbol
Name: second_hand
Registration point: bottom

Convert to Symbol

With the second_hand MovieClip selected, give it the instance name 'second_hand' in its properties panel. (below the stage)

Rename Instance

Lock and Hide the 'Second Hand' layer and select the 'Minute Hand' layer.

Lock and Hide
Repeat Step

Then repeat Step 3 twice to create the minute_hand MovieClip and the hour_hand MovieClip. Typically the minute hand is thicker than the second hand and the hour hand is shorter than both. Remember you can always go into the Library to modify the look of your clock and it's hands later.

Step 5 : Bring the clock to life with Actionscript

Create a new layer above the 'Second Hand' layer, name it 'Actionscript'.

Lock and Hide

Select Frame 1 on the Timeline and open the ActionScript Window.
Window > Actions

Enter the following code: (Explained in comments and below)

Actionscript Code 0

Line 1: Attaches the onEnterFrame function to the clock. The code will execute once per frame.
Line 3 - 6: Gets the current time and stores the hour, minutes and seconds into variables.
Line 8: hour is 0 to 23, this line converts it to the 12 hour clock.
Line 10 - 12: Converts time into an angle.
Line 14 - 16: Rotates each of our MovieClips to the appropriate angle. This is why we named the MovieClip instances: hour_hand, minute_hand, second_hand

Save and Test your progress. You should see a working clock similar to the one below:
Control > Test Movie

Step 6 : Customizing your Clock

Now that you have a functional clock, it is time to have fun customizing it.

Click on the layer you wish to customize, unlock it and make sure it is not hidden.

Then double click the MovieClip on Stage and use the Flash drawing tools to change its color and shape. Have fun!

Test your Movie periodically to see your modifications.

Custom Clock : Concluding Statements

After writing this tutorial, I thought it might be fun to see everyone's custom clocks. So, if I receive at least 10 custom clocks, I'll create a special page for them and continue to add them as they come in.

Submit to:

  • Your .swf file (not the source .fla)
  • Your name/handle (optional)
  • Website Address (optional)

Please keep them under 50kb and no larger than 300x300 px, thanks.

Feel free to send Comments, Questions, and other inquires using the contact page. I hope that you enjoyed the "Customizable Analog Clock" tutorial. View more of my tutorials here.

Like My Work?

I am a professional freelance web developer & graphic designer. These tutorials are a small sample of what I'm capable of. Check out my client portfolio and feel free to contact me. Whether it's a full blown database driven web application or simply a flashy banner design, hire a professional.

Project Sample

Interactive Media : Touch-screen KIOSK Galaxy of Stars

Touch-screen KIOSK
UMO Alumni Directory

Web Development : Artist Gallery MJM Fine Artist Website

Artist Gallery
Parallax Expressionist Art

Print & Graphic Design : Logo & Business Card Design Credit Union Insurance

Logo & Business Card Design
CUinsure Branding


"Working with Max was easy and fun. He understood the feel and look I wanted my site to have. Max is easy to communicate with and very available, always returning emails and answering all of my questions promptly. He also had great suggestions when I had questions about website and business etiquette. In addition to his programming abilities, Max has a great way with people. He has set me up to manage my website easily. I am left feeling confident and proud of my new site."

- Megan Jean Morris, Professional Fine Artist, Farmington, Maine
View More Testimonials

More Tutorials!