Using Director > Behaviors > Writing behaviors with Lingo

 

Writing behaviors with Lingo

If you are familiar with Lingo, you can author your own behaviors.

From the perspective of Lingo, a behavior is a script with these additional features:

Each instance of the behavior has independent values for properties. Lingo uses a property statement to declare properties that can have independent values in each instance of the behavior. See property.

The same set of handlers can be shared by multiple sprites or frames.

The handlers in a behavior are basically the same as other handlers. Include as many handlers as appropriate to implement the behavior.

A behavior is usually attached to multiple sprites or frames. As a result, the sprites and frames share the same handlers. Director tracks which instance of the behavior is which by assigning each instance a reference number. The variable me contains the reference for the object that the instance of the behavior is attached to.

In many cases it's most efficient to create behaviors dedicated to specific tasks and then attach a set of behaviors that perform the variety of actions you want.

The behavior can have parameters that users edit from the Parameters dialog box. The optional on getPropertyDescriptionList handler sets up the Parameters dialog box. See on getPropertyDescriptionList.

A description of the behavior can be added to the Behavior Inspector. The optional on getBehaviorDescription handler displays a description of the behavior in the Behavior Inspector. See on getBehaviorDescription.

A brief description appears as a tooltip for the behavior in the Library palette if the optional on getBehaviorToolTip handler that creates the tooltip has been written. See on getBehaviorTooltip.