Lingo: Behaviors (and the Behavior Inspector).

Use a behavior to add special functionality to a sprite - for example, you can create a button that reacts to a user's click. For our (beginner!) purposes, our behaviors will typically handle any or all of the mouse events (mouseUp, mouseDown, mouseEnter, mouseLeave). For anyone interested in exploring more deeply into Lingo, behaviors can do much, much more!

You can write your own scripts directly in the script window. Or ... you can use the handy Behavior Inspector to do it for you!

Behavior Inspector anatomy

Here's a quick look at the Behavior Inspector. in Director 8.5:

Note: If the inspector doesn't look like this, you can use the little triangles (circled in red) to display & hide panels as needed.

A word about the Behavior Inspector (or "B.I." as we Lingoists like to call it): Keep in mind that, like the Property Inspector, the B.I. tries to be smart. Whenever you click on something - a sprite or cast member, for example - the B.I. will update its contents and tell you all about whatever it was you clicked. Keep your eye on the B.I.'s status line, down at the bottom. If you're confused by the information you're seeing, click again on the object — sprite or cast member — you're interested in.

Example: A simple behavior

In this demonstration, we'll be making a button that, when clicked, sends the movie to the next marker in the score.

  1. Begin with a button onstage. Click once on the button sprite to select it.


  2. Open the Behavior inspector by clicking this button (find it in the toolbar): (or Window:Behavior Inspector).

    Select "New Behavior" from the Behavior popup.

  3. You'll see a small dialog asking you to name this new behavior; type a name (I'm calling it "Next button behavior" here). Click OK. (Note: you've just created a new cast member!)


  4. Now we're ready to build our behavior. Our button should do its thing when it is clicked with the mouse ("mouseUp" is the official name of the event), so select "Mouse Up" from the Event popup button.


  5. Okay, now that we've specified an event for this behavior, we have to assign an action to that event. In this example we want to go (navigate) to the next marker, so choose "Navigation:Go to Marker..." from the Actions popup.


  6. A window will appear, asking you which marker the button should send us to. Choose "next" and click OK.


That's it! If the sprite is still selected, the new behavior should be automatically attached to that sprite. To check this, view your score in "Behavior" mode: choose "Behavior" from that little menu on the left side of the score.



Here's how your sprite should look (assuming you named your behavior "Next button behavior"):



(If the sprite is blank, your behavior is not attached to your button; you can drag it from the cast onto the sprite).

 

Other things you can do with Behavior Inspector

To attach a pre-existing behavior to a sprite:

  1. Select the sprite.
  2. In the B.I., click on the behavior pop-up & choose the existing behavior to attach to the sprite

To remove a behavior from a sprite:

  1. Select the sprite.
  2. In the B.I., click on the clear-behavior button & choose "Remove Behavior" (or "Remove all behaviors" if desired).

Back