Graphics Programs Reference
In-Depth Information
Exercise 6.8: Sinusoidal Motion
In Chapter 5, we looked at a 2D application of sinusoidal motion in the form of a clock
pendulum. Recall that the motion is periodic and, roughly speaking, repeats itself in a
back-and-forth manner. In this exercise we will explore some of the potential of sinusoi-
dal motion in 3D. Here we will look at motion that goes in and out. To see where we are
initially headed, open 6_8_zSineMotion1.swf as a reference.
Step 1: Getting started
Open 6_8_zSineMotion.fla. It's not much of a file, just a background layer and an
actions layer with nothing in it. Still, it meets our needs, so we'll give it our stamp of
approval. We're going to be using some bitmaps for our objects. Rather than reinvent-
ing the wheel, we can use Exercise 6.6 as a starting point. Since you probably don't
want to type any more than you have to, also open xzRotation4.fla . As a first step,
copy the script from xzRotation4.fla and paste it into 6_8_zSineMotion.fla .
Step 2: Get some objects
Since we're using different images, we just need to replace one line of code as shown
below to dynamically load them as we did in Exercise 6.6.
22
23
24
25
26
27
// create the objects for the circular motion
for (var i:Number = 0; i < numberOfObjects; i++)
{
this.createEmptyMovieClip("object"+i, i);
this["object"+i].loadMovie("stamps/fame"+(i+1)+".jpg");
}
If you are of a curious nature, you may have looked inside the stamps folder and
discovered that there are 10 stamps and not 8 as we have specified. So let's make
another simple change and set the number of objects to 10.
14
15
16
17
// set the number of objects to be created and startAngle
var numberOfObjects:Number = 10;
var startAngle:Number = 0; // starting rotation angle
var speedfactor:Number = 40; // controls speed of motion
Test your movie at this point to make sure the images are loading properly. You should
get circular rotating objects as in Figure 6.35.
 
Search WWH ::




Custom Search