
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
368
|
Chapter 13: Movie Clips
// Highlight item_mc when it is focused
item_mc.onSetFocus = function ( ) {
this.doHighlight( );
}
// Remove highlight from item_mc when it loses focus
item_mc.onKillFocus = function ( ) {
this.doRemoveHighlight( );
}
// Remove item_mc when "x" is pressed and item_mc has focus
item_mc.onKeyDown = function ( ) {
if (Key.getCode( ) = = 88) { // The keycode for "x" is 88
this.removeMovieClip( );
}
}
For much more information on movie clip input focus, consult the Language Refer-
ence entries for the properties and methods discussed in this section.
Building a Clock with Clips
Now that you’ve learned the fundamentals of movie clip programming, let’s put this
knowledge to use by creating a sample analog clock application, which exemplifies
the typical role of movie clips as basic content containers. See also the various ver-
sions of the multiple-choice quiz posted at the online Code Depot.
In this chapter we saw how to create movie clips with attachMovie() and how to set
movie clip properties with the dot operator. With these relatively simple tools and a
little help from the Date and Color classes, we have everything we need to make a
clock with functional hour, minute, and second hands.
First, we’ll make the face and hands of the clock using the following steps