User Guide
284 Chapter 12: Behaviors
• #range specifies a range of possible values that the user can assign to the property. Specify the
possible values as a list.
To specify a range between a minimum and maximum number, use the form [
#min:minimum,
#max:maximum
]. The example sets the range from 1 to 10. When the range is between a
maximum or minimum number, the Parameters dialog box provides a slider that sets the value.
To specify no range, omit the
#range parameter. If the property’s definition does not include
#range, a text entry field appears for the user to enter a value in the Parameters dialog box.
To specify a set of possible choices, use a linear list. For example, the list
[#mouseUp,
#mouseDown, #keyUp, #keyDown]
makes these four events possible choices for a parameter.
When you specify values in a linear list, the choices appear in a pop-up menu in the
Parameters dialog box. (For this example list, you need to specify
#format: #symbol for
the list to display correctly.)
As another example, this statement defines the property
whichSound:
description.addProp(#whichSound, [#default: "", #format:#sound, #comment: \
"Which cast member"]
The value #sound assigned to #format provides a pop-up menu in the Parameters dialog box that
includes every sound cast member available in the movie.
If the behavior includes a method that plays a sound, this property can be used to specify a sound
cast member to play. For example, if the user selects Growl from the pop-up menu in the
Parameters dialog box, the statement
puppetSound whichSound would play the sound cast
member Growl.
Creating an on getPropertyDescriptionList handler
To build a list of properties for a behavior, add each property to the list that the
on getPropertyDescriptionList handler returns. Then use the return method to return
the list.
For example, this handler creates a property list named Description that contains the definitions
for
movement and whichSound:
--Lingo syntax
on getPropertyDescriptionList
description = [:]
description[#movement] = \
[#default: 5, \
#format:#integer, \
#comment: "Set motion to the right:", \
#range: [#min:1, #max:10] \
]
description[#noise] = \
[#default:"", \
#format: #sound, \
#comment:"Sound cast member name" \
]
return description
end