Graphics Programs Reference
In-Depth Information
77
78
79
80
81
82
83
84
// check for a negative frame number
if (thisFrame < 0 ) { thisFrame += totalFrames; }
// display the current frame of the object
object_mc.gotoAndStop(thisFrame % totalFrames);
// loop over all the objects
Note that we need the test in line 79 since we can have negative angles that will
generate corresponding negative values for thisFrame .
The final addition to our script is to go to the correct frame of the object movie clip as
shown in line 82. We again use the modulo function to guarantee that we stay within
the range of the movie clip's frames. Save and test your movie. You should get some
pretty wild behavior of the object as it follows the path. Let's pull in the reins a little bit.
Step 6: The finishing touch
Although our reasoning was sound, we now need to refine the relationship between
thisFrame and startAngle . We would like to have the object facing us at the nearest
point on the circular path. Recall that the path starts out at 0 degrees along the x-axis.
However, the first frame of the object movie clip shows it facing somewhat towards us
as shown on the left side of Figure 8.7. But at 0 degrees, the object should be looking
along the x-axis as it is in frame 32, and shown on the right side of Figure 8.7.
Figure 8.7 The object movie clip at frames 1 and 32
What we need is to start at frame 32 of the object movie clip rather than at frame 1.
There is one other problem with the motion that you may discover if you look closely.
 
Search WWH ::




Custom Search