User Guide
Example: Alarm Clock 365
Example: Alarm Clock
The Alarm Clock example consists of a clock that allows the user to specify a time at which an
alarm will go off, as well as a message to be displayed at that time. The Alarm Clock example
builds on the SimpleClock application from Chapter 6, “Working with Dates and Times.”
Alarm Clock illustrates several aspects of working with events in ActionScript 3.0, including:
■ Listening and responding to an event
■ Notifying listeners of an event
■ Creating a custom event type
The Alarm Clock application files can be found in the Samples/AlarmClock folder. The
application includes these files:
Alarm Clock overview
The primary functionality of the clock in this example, including tracking the time and
displaying the clock face, reuses the SimpleClock application code, which is described in
“Example: Simple analog clock” on page 204. The AlarmClock class extends the SimpleClock
class from that example by adding the functionality required for an alarm clock, including
setting the alarm time and providing notification when the alarm “goes off.”
File Description
AlarmClockApp.mxml The main application file in MXML for Flex.
com/example/programmingas3/clock/
AlarmClock.as
A class which extends the SimpleClock class,
adding alarm clock functionality.
com/example/programmingas3/clock/
AlarmEvent.as
A custom event class (a subclass of
flash.events.Event) which serves as the event
object for the AlarmClock class’s
alarm event.
com/example/programmingas3/clock/
AnalogClockFace.as
Draws a round clock face and hour, minute, and
seconds hands based on the time (described in
the SimpleClock example).
com/example/programmingas3/clock/
SimpleClock.as
A clock interface component with simple
timekeeping functionality (described in the
SimpleClock example).