Graphics Programs Reference
In-Depth Information
example, with eight objects as shown in Figure 5.22, circleAngle will be equal to
360/8, or 45 degrees.
circleAngle
Figure 5.22 Illustration of circleAngle
10
11
12
// calclate the angle between any two objects on a circle
circleAngle = 360/numberOfObjects;
Step 4: Create the objects
We can now write a script, shown below, to create the objects that will be distributed
equally around the circle. To do this, we will use a for loop that starts counting at 0,
goes to 1 less than the number of objects specified, and increments by 1 each time
through the loop. For each iteration of the loop we are duplicating the original object
movie clip, object_mc , then naming it and setting its depth value. The duplicated clips
are named “ object0” at depth 0, “object1” at depth 1, and so forth, up to and
including “object7” at depth 7.
13
14
15
16
17
18
// create the objects desired for the circular motion
for (i = 0; i < numberOfObjects; i++)
{
object_mc.duplicateMovieClip("object"+i, i)
}
 
Search WWH ::




Custom Search