Macromedia Flash 8 for Windows & Macintosh

With the right script attached, movie-clip symbols can act as if they're buttons. When you add the on (mouseEvent) handler to a movie clip, Flash creates a hit area for you from the graphic elements in the currently displayed frame of the movie clip. When a user positions the pointer over the scripted movie clip, Flash changes the pointer to the pointing hand cursor, indicating that this movie clip can respond to mouse movements. To get the most assistance with this type of script, use the Behaviors panel.

To add actions to make a movie clip duplicate itself

1.

Open a new Flash document, and open the Behaviors and Actions panels.

2.

Place an instance of a movie-clip symbol on the Stage.

Create a new movie-clip symbol (see Chapter 11) or bring one in from an existing document.

3.

Select the movie-clip instance.

The Actions panel name changes to Actions - Movie Clip. The Behaviors panel displays a movie-clip icon and the name of the selected movie clip.

4.

In the Behaviors panel, from the Add Behavior menu (click the plus sign to access the menu), choose Movieclip > Duplicate Movieclip.

The Duplicate Movieclip dialog appears. This dialog helps you to supply values for the required parameters of the duplicate MovieClip action (Figure 13.44).

Figure 13.44. The Duplicate Movieclip dialog contains the parameters required for letting users make copies of movie clips by clicking a button symbol or movie clip. The offset values define the location of the duplicate.

5.

In the dialog, do the following:

  • In the target movie-clip pane, select the movie clip that you want to duplicate. Note that you can't duplicate the main movie, so don't select _root. Your movie-clip instance will appear indented beneath _root. If you haven't named the instances, the movie-clip name appears in parentheses.

  • For the pathname style, select Relative.

  • Enter values for X-offset and Y-offset. These tell Flash where to position the movie clip copy in relation to the original. To make the duplicate appear far away from its original, enter large values.

6.

Click OK.

Flash adds the behavior to the Behaviors panel and adds comments and code to the Script pane of the Actions panel (Figure 13.45).

Figure 13.45. The script for the Duplicate Movieclip behavior gives you some idea of the complexity of advanced ActionScripting. This script must account for naming each duplicate movie-clip instance and placing it on its own sublayer (or level) of the frame to ensure that all instances appear correctly and don't interfere with one another. Still, the basic parameters you set up in the dialog are there.

You're ready to try out the movie clip that responds to mouse movements. During playback, as you move the pointer over the movie clip, the pointing-hand cursor appears. When you click and release within the movie-clip area, Flash makes a copy of the clip. Click the original or the copy to make another duplicate.

Категории