
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Further Exploration
|
421
To start our clock application in motion, we invoke Clock.main( ) on a frame of a .fla
file (presumably the frame following any preloader). For example:
// Import the package containing the Clock class.
import mvcclock.Clock;
// Attach the clock to someClip. The time defaults to the system time.
Clock.main(someClip);
As mentioned earlier, the .fla file’s Library must contain a movie clip symbol named
ClockAnalogViewSymbol, and it must contain the Button UI component. (To add the
Button component to the Library, drag an instance of it from the Components panel
to the Stage, and then delete the instance from the Stage.)
In the preceding example, if we had chosen to set the time of the clock to 3:40:25 a.m.,
we’d have used:
Clock.main(someClip, 3, 40, 25);
In either case, a clip referenced by the variable or instance name “someClip” must
exist on the timeline.
To create a clock set to 3:40:25 p.m. and attach it to the current timeline, we can
use:
Clock.main(this, 15, 40, 25);
Alternatively, we could create an instance of the Clock class directly (skipping the
main( ) method) like this:
var c:Clock = new Clock(this, 15, 40, 25);
We’d need to use that approach when creating a clock as part of a larger applica-
tion. The main( ) method approach simply lets us use the clock ...