Customizable Analog Clock

Adobe Flash Tutorials :

Category: Adobe Flash Tutorials
Added: 04/03/2007
Views: 80,354

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

Web Development : University Department UMaine ECE Departmental Website Design

University Department
Academic Website Redesign

Web Development : Custom Google Map Solution Land of First Contact Historical Atlas

Custom Google Map Solution
Learn about historical locations in Northern Newfoundland and the Strait of Belle Isle.

Print & Graphic Design : DVD Design Alaska Folk Festival

DVD Design


"I have worked with Max Langdon for almost five years. Max is not only a talented web designer and programmer, but he has an added quality that I find quite rare. He is able to really listen to and understand the client's vision. He asks excellent questions that help you zero in on exactly what you are trying to accomplish. This helps you clarify your goal and allows Max to think through the scope and sequence of the process before beginning to program. This saves him time and saves you money.

Working with Maxwell Langdon and his company, Pixel Hive has been a pleasure. I have always found him to be responsive and helpful. There is no "attitude" when you ask for an explanation or guidance.

I would be happy to speak with anyone who is thinking of working with Max. "

- John Burstein, Slim Goodbody Corporation, Lincolnville Center, ME
View More Testimonials

More Tutorials!