• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 16. Adding Behaviors > Creating Behaviors

Creating Behaviors

Although Director's built-in behaviors provide a wealth of interactive possibilities, you may need to go further and create your own custom behaviors. This section shows you how to do so and provides two simple examples. One example behavior triggers a beep when a user clicks a sprite. The other example is a navigation behavior that makes the movie reset to a specific frame when the user removes the mouse pointer from a sprite.

To create a behavior:

Open the Behavior Inspector.

Choose New Behavior from the Behavior pop-up menu (Figure 16.12).

Figure 16.12. Choose New Behavior from the Behavior pop-up menu.

The Name Behavior dialog box opens.

Type a name for the behavior and click OK (Figure 16.13).

Figure 16.13. Name the new behavior.

The behavior is added to the cast window as a behavior cast member. So far, the cast member is an empty shell.

Next, you need to define the behavior by specifying which actions should occur in response to specific events.

If necessary, click the triangular open-pane buttons in the Behavior Inspector to display the editing and description panes.

Choose from the Events pop-up menu an event that should trigger your behavior's action (Figure 16.14).

Figure 16.14. Use the Events and Actions pop-up menus to specify which actions occur in response to which events.

From the Actions pop-up menu, choose a category of action and then a specific action that the event should trigger.

Set parameters, if necessary, for the given action.

Repeat steps 5–7 to add as many events and actions as necessary.

Remember that a behavior can have multiple events, and each event can trigger multiple actions. Actions for any event are executed in the order listed in the Actions list.

Close the Behavior Inspector.

Drag the behavior from the cast window to a sprite in the movie or a frame in the score.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint