Graphics Programs Reference
In-Depth Information
Figure 5.18 Circular motion of one object
Step 1: Getting started
Open the 5_1_circRotation.fla file in the Chapter 5 folder. Our objective is to use
ActionScript to get the ball travelling in a circular motion around the rim of the roulette
wheel. Our movie consists of five layers. The background layer holds a copy of the rou-
lette wheel. A mask layer has been created with instance name mask_mc to define the
edge of the rim around which the ball will travel. The masked layer has a second copy
of the roulette wheel named wheel_mc . This wheel will move in the opposite direction
to the ball. The white ball is held in the ball layer with a movie clip named object_mc .
The actions layer will contain our script that makes everything work.
Step 2: Define the path characteristics and object starting angle
The first thing we need to do is to provide some information about the circular path the
object will follow. Let's place the center of the circle (xc,yc) in the center of the Stage
by setting xc = Stage.width/2 and yc = Stage.height/2 .
We also need to set the radius of the circular path the ball will follow. In many situations
the radius is known explicitly at the outset by construction. In this example, we will let
Flash calculate the radius for us. Referring to Figure 5.19, the desired radius r is equal
to the radius of the wheel rim (the mask) minus the radius of the ball. In both cases, the
radius of each is equal to half of the width of each so that
r = (Mask width ) / 2 - (Ball width) / 2
Search WWH ::




Custom Search