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 (,
, ,
). 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:

- The behavior panel lists the behaviors themselves. Select a behavior
cast member in the cast, and its name will appear here. Select a
sprite & this window will show you what behavior(s), if any, are
currently attached to that sprite. To learn more about a behavior,
click on it!
- The events panel shows what events are in the currently-selected behavior.
- The actions panel shows what actions there are for the currently-selected
event in the currently-selected behavior.
- The description panel can be used to create & display notes on how to
use a behavior (we will ignore this panel in my class).
- The Script Window button opens the behavior in the script window.
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.
- Begin with a button onstage. Click once on the button sprite to select
it.
- Open the Behavior inspector by clicking this button (find it in the toolbar):
(or ).
Select "New Behavior" from the Behavior popup.
- 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!)
- 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.

- 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.

- 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:
- Select the sprite.
- 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:
- Select the sprite.
- In the B.I., click on the clear-behavior button & choose "Remove
Behavior" (or "Remove all behaviors" if desired).

Back