•
The behavior can have parameters that users edit from the Parameters dialog box. The optional
on getPropertyDescriptionList
information, see the Scripting Reference topics in the Director Help Panel.
•
A description of the behavior can be added to the Behavior inspector. The optional
getBehaviorDescription
inspector. For more information, see the Scripting Reference topics in the Director Help Panel.
•
A brief description appears as a tooltip for the behavior in the Library palette if the optional
getBehaviorToolTip
information, see the Scripting Reference topics in the Director Help Panel.
Setting up a Parameters dialog box
It is impossible to predict exactly what a user will want behaviors to do. You can make behaviors
more flexible by letting the user customize the behavior's parameters.
For example, this handler moves the sprite 5 pixels to the right each time the playhead enters a
new frame:
if ( sprite(me.spriteNum).locH > window("stage").rect.right ) then
sprite(me.spriteNum).locH = window("stage").rect.left
else
sprite(me.spriteNum).locH = sprite(me.spriteNum).locH + 5
end if
However, users could adjust the speed of each sprite if they could specify how far individual
sprites move to the right in each frame.
To allow users to set different values for a property in different instances of the behavior, the
behavior's script needs the following:
•
A
statement (Lingo) or a
property
to maintain a separate value for the property
•
An
on getPropertyDescriptionList
Setting behavior properties with script
Behaviors usually have properties for which each instance of the behavior maintains its own
values. (An instance is the unique instance of the behavior assigned to sprites or frames.) These
properties are shared among handlers in a behavior's script the same way that properties are shared
among handlers in an object.
To declare properties in each instance of the behavior:
•
Put the
property
A
or
property
var
individual properties or variables. For example, the statement
is a property of the behavior.
movement
282
Chapter 12: Behaviors
handler sets up the Parameters dialog box. For more
handler displays a description of the behavior in the Behavior
handler that creates the tooltip has been written. For more
var
or
statement at the beginning of the behavior's script.
var
statement starts with the word
statement (JavaScript syntax) that allows each instance
handler that sets up the property or variable.
or
property
var
property movement
on
followed by the names of the
declares that
on
Need help?
Do you have a question about the DIRECTOR MX 2004-USING DIRECTOR and is the answer not in the manual?
Questions and answers