Applied Movie Clip Examples
We’ve now learned the fundamentals of movie clip programming. Let’s put our knowledge to use by creating two very different applications, both of which exemplify the typical role of movie clips as basic content containers.
Building a Clock with Clips
In
this chapter we learned 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 with the following steps (notice that we don’t place the parts of our clock on the main Stage—our clock will be generated entirely through ActionScript):
Start a new Flash movie.
Create a movie clip symbol named
clockFace
that contains a 100-pixel-wide black circle shape.Create a movie clip symbol named
hand
that contains a 50-pixel-long, vertical red line.Select the line in
hand
, then choose Window → Panels → Info.Position the bottom of the line at the center of the clip by setting the line’s x-coordinate to and its y-coordinate to -50.
Now we have to export our clockFace
and
hand
symbols so that instances of them can be
attached dynamically to our movie:
In the Library, select the
clockFace
clip, then select Options → Linkage. The Symbol Linkage Properties dialog box appears.Select Export This Symbol.
In the Identifier box, type
clockFace
and then click OK. ...
Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.