Authortime Assignment of Property Dialog Box Defaults in Director 6
August 20, 1998
by Andy Rose
One of the powerful features of behaviors in Director 6 is the ability to specify a dialog box so that authors can assign values to behavior properties, as outlined in Director 6 Learning Lingo, Chapter 15, Authoring Behaviors. The below Lingo script illustrates how the choices presented to an author when a behavior is dragged to a sprite can be generated "on the fly". In this example, the value of the #range property which is returned by getPropertyDescriptionList is generated by examining the score.
Some reasons to use this technique are setting defaults that make sense according to which sprite the behavior was dragged to, or which member that sprite uses, or, in this case, the position of the playhead when the behavior is dragged.
In this example, the property dialog box shows a popup with all the members that appear in the score up to the current frame. This can be used for authoring streaming behaviors where a choice of members that are already streamed is presented to the user (members stream in score order). Here is the lingo to do this.
Clarifications:
- beginsprite? Just an example.
- the currentspritenum <> 0
This is because getPropertyDescriptionList is run whenever a behavior is clicked on in a cast. If this value is 0, the behavior was not dragged anywhere. If it is nonzero the behavior was dragged to a sprite. Skip all this stuff if the behavior was not actually dragged somewhere. - the GetPos, add stuff? If the member is already in the list, don't add it.
- sort (result)? take it out to have the members appear in the list in score order
- go frame cf? returns the playhead to where it was
- #range? That's what makes the popup happen. see page 153 Dir 6 Lingo Dictionary
To try this out, simply assign the behavior to a sprite in the score. The first time the behavior gets attached to the sprite, Director 6 pops up a dialog that lets the user set the properties that are specified in the behavior. Then when run, the sprite will display the the cast member you set it to when the behavior was first applied.
property example
on beginsprite me
set the member of sprite the spritenum \
of me = member (value(example))
end
on getPropertyDescriptionList
if the currentspritenum <> 0 then
set cf = the frame
set result = []
repeat with j = 1 to cf
go frame j
repeat with i= 1 to 120
set x = string (the member of sprite i)
if x <> "(member 0 of castlib 0)" then
set y = the name of the member of sprite i
if y = "" then set y = x
if GetPos (result, y) = 0 then
add (result,y)
end if
end if
end repeat
end repeat
sort (result)
go frame cf
end if
return ([#example: [#format:#string, #default:"null",\
#comment:"member", #range:result]])
end
Copyright 1997-2025, Director Online. Article content copyright by respective authors.