Graphics Programs Reference
In-Depth Information
Next we need to add the test for the spacebar and Shift keys below the previous key
tests. For the Shift keys we will increase the number of objects by 1 and then call our
initObjects() function to create a new set of dolphins.
For the spacebar, we need to do a similar thing, but we also have to physically remove
an object from the Stage. We first reduce the number of objects by 1. Because we
begin counting the object numbers at 0, the new value of the numberOfObjects repre-
sents the top object which can be removed using removeMovieClip() . We then call the
initObjects() function to generate a new set.
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// use the shift keys & spacebar
// to change the number of objects
if ( Key.isDown(Key.SHIFT) )
{
numberOfObjects += 1;
initObjects();
}
if ( Key.isDown(Key.SPACE) )
{
numberOfObjects -= 1;
this["object"+numberOfObjects].removeMovieClip();
initObjects();
}
}
That should do it. Add a text layer with instructions if you wish. Save your movie as
5_3_dolphinSwim2.fla. Don't forget to use all six keys to make the dolphins perform.
Elliptical Motion
If you have ever used Photoshop, Illustrator, Flash, or a host of other programs, you
know that you select the Oval tool to generate circles as well as ellipses, the fancy
name for ovals. The reason is that circles are simply special cases of ellipses. We
know that all circles have a uniform radius. Perhaps it is easiest to think of ellipses as
stretched circles with a horizontal radius xr and a vertical radius yr as shown in Figure
5.24. When xr = yr, you have a true circle. If you want to get a feel for how changing
xr and yr affects the overall elliptical shape, open the ellipsor.swf file in the Chapter
5 folder.
Search WWH ::




Custom Search