Articles Archive
Articles Search
Director Wiki
 

getPropertyDescriptionList tips

October 29, 2000
by Pat McClellan

Dear Multimedia Handyman,

I'm using this behavior that I'm dropping on my sprites and I would like to pass the sprite's locH and locV as default values in the getPropertyDescriptionList. I tried using...

x = me.spriteNum.locH
y = me.spriteNum.locV

...but that doesn't work! Is there a way to know these values as I drop the behavior on the sprite?

Adrien Claude

Dear Adrien,

The reason it doesn't work is that at the moment you drop it on the sprite, there is no reference for me. Instead, you'll need to use the currentSpriteNum. This property is a Movie property that indicates the channel number of the sprite whose script is currently running. This applies even if the movie is not running -- such as when you're authoring and dropping behaviors!

Building in default values is courteous to others who might use the behaviors, and it's also a great timesaver. I like to set all of the default values into variables at the top of the gpdl handler, then plug those variables into the #default property when I'm building the property list. Take a look at this example, with a graphic of the resulting dialog box.

property pLocH, pLocV, pSlider, pFloatField, pPullDown, pBoolean

on getPropertyDescriptionList me

  defaultH = sprite(the currentSpriteNum).locH
  defaultV = sprite(the currentSpriteNum).locV
  sliderRange = [#min: 3.0, #max: 8.5]
  pullDownList = [#cherry, #grape,#apple,#melon, #lemon]

  pdlist = [:]

  addprop pdlist, #pLocH, [#comment:"locH:", #format:#integer, #default:defaultH]
  addprop pdlist, #pLocV, [#comment:"locV:", #format:#integer, #default:defaultV]
  addprop pdlist, #pSlider, [#comment:"Slider:", #format:#float, #default: 5.25, #range: sliderRange]
  addprop pdlist, #pFloatField, [#comment:"Field:", #format:#float, #default: 5.25]
  addprop pdlist, #pPullDown, [#comment:"Pulldown:", #format:#symbol, #default:#apple, #range: pullDownList]
  addprop pdlist, #pBoolean , [#comment:"Checkbox:", #format:#boolean, #default:1]

  return pdlist

end

Director 7 download for Mac or Windows.

I included some other nifty gpdl features in this sample movie. Note that you can generate a slider simply by providing a range. If you specify a range that is a list, the property selection mode shows up as a pulldown menu. And checkboxes are super-easy, achieved by specifying a boolean format.

getPropertyDescriptionList handlers can be a bit taxing to write, but the result is definitely worth the effort!

Patrick McClellan is Director Online's co-founder. Pat is Vice President, Managing Director for Jack Morton Worldwide, a global experiential marketing company. He is responsible for the San Francisco office, which helps major technology clients to develop marketing communications programs to reach enterprise and consumer audiences.

Copyright 1997-2024, Director Online. Article content copyright by respective authors.