Graphics Programs Reference
In-Depth Information
Save your movie as 5_2_fishFerris.fla and test it. You should see the eight fish
rotating in a counterclockwise circular orbit. There's just one small problem. Even
though we layered the graphics so that the fish would be inside the supports, they are
not doing what they are supposed to do. Here's why. Any object on the Stage has a
depth value that reflects the Flash layering. Objects using Flash layers typically all have
depth values around -16384. When we duplicated object_mc , we set the depth of its
copies to 0, 1, 2, etc. Consequently, they all have higher depth values than the layered
graphics and will be on top of all of them.
Can we still get the supports on top? Yes, we can by using two handy ActionScript func-
tions, getNextHighestDepth() and swapDepths() . The first returns the next available
depth value, and the second enables a movie clip to swap its current depth for another
depth. Insert the following lines as shown before the frame loop, and all will be fine.
Save and test the results.
19
20
21
22
23
// put the frame outside of the objects
frame_mc.swapDepths(getNextHighestDepth());
// create the circular motion
this.onEnterFrame = function()
Exercise 5.3: Circular Motion Extended
Now that we can have objects move along a circular path, let's push this idea a little
further. One of the limitations of the previous exercise is that all of the fish were point-
ing in the same direction. While it was appropriate for that application, it would be nice
if we also knew how to get each of the objects to point in a different direction for a
more symmetrical arrangement around the center. Something suggestive perhaps of
dolphins performing synchronized swimming as in Figure 5.23. For an animated refer-
ence, open 5_3_dolphinSwim1.swf in the Chapter 5 folder.
Step 1: Getting started
Open 5_3_circRotation.fla in the Chapter 5 folder. At this point, other than the
number of objects and the circle radius, it has basically the same script as the previous
exercise except that the motion is in a clockwise direction. Choose Control > Test Movie
to verify the similar motion.
 
Search WWH ::




Custom Search