Creating and Modifying Behaviors

   

Although the behaviors in the Library palette were created by professional programmers using advanced Lingo, it's possible to create simple behaviors of your own using the tools available in the Behavior Inspector. This section shows you how to create a new behavior and how to modify it later.

To create a behavior:

  1. Open the Behavior Inspector.

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

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

    graphics/14fig20.gif

    The Name Behavior dialog box opens.

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

    Figure 14.21. In this example, we'll create a behavior that beeps and sends the playhead back to frame 1 when the user clicks a sprite. Let's call it Rewind.

    graphics/14fig21.gif

    The dialog box closes . The newly named (but still empty) behavior is added to the Cast window ( Figure 14.22 ), and its name is displayed in the upper pane of the Behavior Inspector.

    Figure 14.22. The new behavior appears in the Cast window as soon as it's named.

    graphics/14fig22.gif

  4. If necessary, click the expander arrow to display the Behavior Inspector's editing pane.

  5. From the Event pop-up menu, choose an event that will trigger your behavior ( Figure 14.23 ).

    Figure 14.23. Choose an event that will trigger the behavior. For the Rewind behavior, we'll choose Mouse Down.

    graphics/14fig23.gif

    The selected event appears in the left column of the editing pane.

  6. From the Action Popup menu, choose a category of action and then a specific action that the event will trigger ( Figure 14.24 ).

    Figure 14.24. Choose an action that the event will trigger. For the Rewind behavior, we'll choose Navigation > Go to Frame.

    graphics/14fig24.jpg

  7. If a parameters dialog box appears, set parameters for the selected action and click OK ( Figure 14.25 ).

    Figure 14.25. If a parameters box appears for the selected action, choose your settings and click OK.

    graphics/14fig25.gif

    The selected action appears in the right column of the editing pane.

  8. Repeat steps 5 through 7 as many times as necessary to add as many events and actions as you want ( Figure 14.26 ).

    Figure 14.26. An event may trigger multiple actions. In this case, the Sound > Beep action is added.

    graphics/14fig26.gif

    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.

    When events and actions are selected, they automatically become part of the behavior. You don't have to do anything special to make them "stick."

  9. Assign the behavior by dragging it from the Cast window to a sprite or frame ( Figure 14.27 ).

    Figure 14.27. The Rewind behavior is dragged to a sprite (a rewind button) on the Stage.

    graphics/14fig27.gif

graphics/tick.gif Tip

  • Always play back the movie to check the new behavior and then adjust the behavior settings, if necessary.


To modify a behavior:

  1. Open the Behavior Inspector.

  2. In the Score, select a sprite or frame that has a behavior assigned to it.

    or

    Choose a behavior from the Behavior Popup menu in the Behavior Inspector ( Figure 14.28 ).

    Figure 14.28. The Behavior Popup menu lists all behaviors in the cast that could potentially be applied to the currently selected sprite or frame.

    graphics/14fig28.gif

    or

    Select a behavior in the Cast window.

  3. If the Behavior Inspector displays a list of behaviors, select the one you want to modify.

  4. If necessary, click the expander arrow to display the Behavior Inspector's editing pane.

  5. If you want to add events or actions, follow steps 5 through 7 in "To create a behavior," above.

  6. If you want to delete an event or action, select the event or action you want to delete and do one of the following:

    • Click the Clear Event or Clear Action button ( Figure 14.29 ).

      Figure 14.29. These buttons in the editing pane allow you to modify behaviors.

      graphics/14fig29.gif

      or

    • Press the Delete key.

  7. If you want to change the order of actions attached to a particular event, select the action you want to move and click the Shuffle Up or Shuffle Down button.

    There's no need (and no way) to change the order of events in a behavior. Director will respond to any of the listed events when it occurs, regardless of its place in the list.

    Any changes you make to a behavior take effect automatically.

graphics/tick.gif Tip

  • Any changes you make to a behavior affect all instances of that behavior that are already assigned to sprites or frames .


   


Macromedia Director MX for Windows and Macintosh. Visual QuickStart Guide
Macromedia Director MX for Windows and Macintosh. Visual QuickStart Guide
ISBN: 1847193439
EAN: N/A
Year: 2003
Pages: 139

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net