User Guide

Example: Simple analog clock 205
The class has two important properties:
The face property, which is an instance of the AnalogClockFace class
The ticker property, which is an instance of the Timer class
The SimpleClock class uses a default constructor. The initClock() method takes care of the
real setup work, creating the clock face and starting the Timer instance ticking.
Creating the clock face
The next lines in the SimpleClock code create the clock face that is used to display the time:
/**
* Sets up a SimpleClock instance.
*/
public function initClock(faceSize:Number = 200)
{
// creates the clock face and adds it to the display list
face = new AnalogClockFace(Math.max(20, faceSize));
face.init();
addChild(face);
// draws the initial clock display
face.draw();
The size of the face can be passed in to the initClock() method. If no faceSize value is
passed, a default size of 200 pixels is used.
Next, the application initializes the face and then adds it to the display list using the
addChild() method inherited from the DisplayObject class. Then it calls the
AnalogClockFace.draw() method to display the clock face once, showing the current time.