by William Hurley

Random Calls in a Shockwave Movie



This week I address the issue of random commands in Shockwave movies. The random command allows you to "randomize" many of the functions of Lingo. This can be very useful for Shockwave in creating random hypnotic effects with moving objects.

This week's Shockwave column demonstrates the use of the random command to create a screen saver-like effect with blue and red balls. Let's take a look at how the random command is being used in each movie, and how you can use this in your own Shockwaves.

A Look at the Blue Ball Movie

In this movie we have an area that is about 250 pixels in width and 50 pixels in height. The goal of creating this movie was to add some random animation onto the stage area so that it would be filled with balls, creating a similar look and feel of a screen saver.

The steps for creating the blue ball movie follow. It is important to note that we first created the graphic of the ball in xRes using a KPT filter. However, you can use any graphic you wish for this tutorial; experimentation is encouraged.

Steps for Creating the Blue Ball Movie.

Step 1: Set the stage size in Director to 250 pixels in width and 50 pixels in height. To do this choose "Preferences" from the file menu. This will open the window as shown in Figure 1. Set the stage size and make sure that the stage will be centered on the screen; then click the button marked OK.

Figure 1

Step 2: Import a graphic into the Cast window. Again we used the blue ball, but you can use anything that you would like for this step.

Step 3: Position the graphic you have imported in the center of the Stage window, as shown in Figure 2. This will make the starting position for the graphics movement the center of the stage.

Figure 2

Step 4: Now double-click the Score Script at Frame 1. Enter the following Lingo script into the window provided.

on exitFrame
  set the locH of sprite 1 = random(250)
  set the locV of sprite 1 = random(50)
  go to the frame
end

This will cause the ball to randomly move around on the Stage. The first line of Lingo sets the horizontal position of the graphic (as sprite 1) to anywhere in a random area that is limited to 250 pixels in width. The second line of Lingo sets the vertical position of the graphic (as sprite 1) to anywhere in a random area that is limited to 50 pixels in height.

Step 5: Now we need to allow the graphic to move and to leave a trail for every position it appears on the stage. This is what gives us the tracer effect. To do this select the graphic in the Score window at frame 1 and then click "moveable" and "trails" as shown in Figure 3.

Figure 3

Step 6: The last thing we need to do is set sprite 1 to the "background transparent" setting. This will knock out any white space that may be surrounding the graphic you choose to use for this tutorial.

In the red ball movie we simply changed the random(250) to random(200) and then deleted the second statement so that the vertical position of the object could not change. This technique can be very useful in creating some really great animations for Shockwave.

Try experimenting with different objects and different settings for the horizontal and vertical positions. Until next week . . .

Past installments of Simply Shocking

http://www.internet.com/