
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
An MVC Clock
|
411
We’ve now seen two view classes that do not accept user input and therefore have no
controller. Next, we’ll consider a view class, ClockTools, which accepts user input
and shows how to process that input with a controller.
The ClockTools Class
Like the ClockAnalogView and ClockDigitalView classes, the ClockTools class is a
view for ClockModel, so it extends AbstractView. The ClockTools class creates the
Start, Stop, and Reset buttons below the analog and digital clock display, as shown
in Figure 18-3. A .fla file that uses ClockTools must contain the Flash MX 2004 But-
ton component in its Library and have it exported for ActionScript (see Chapter 12
for information on components).
Unlike ClockAnalogView and ClockDigitalView, the ClockTools view includes a func-
tional controller to process user input. The general structure of ClockTools follows
the structure of ClockAnalogView and ClockDigitalView—ClockTools has a
makeTools( ) method that creates the user interface and an update( ) method that
makes changes to that interface based on ClockModel updates. However, the
makeTools( ) method does more than just render the user interface; it also creates the
all-important connection from that interface to the controller (and, indeed, creates
the controller itself).
Because