Articles Archive
Articles Search
Director Wiki

Dynamic cast assignment

June 25, 2000
by Pat McClellan

Dear Multimedia Handyman,

We work a lot on huge CD catalogs, which we produce in Director. The main principle here is to have pages for thumbnails and a page for each of the items represented by the thumbnails. The thumbnail icons usually have "go to marker" behaviour. And if we have about 10000 thumbnails we have to write 10000 "go to marker" behaviours! We would be very grateful if you could help us to automate this process.

Alexei Loginov, Russia St.Petersburg

Dear Alexei,

Good question! The way to do this is to set up a single "display" frame in which the large photo or graphic, price and text information is displayed. This display frame will have sprites that serve as placeholders for the product-specific castmembers. The appropriate castmembers get dynamically placed in those sprites whenever you go to the display page. This assignment is based on the names of the cast members, so let's look at the naming process.

All items need a naming convention. For example, you might have a cast member named item30294 that is the thumbnail of a product, and a second cast member named item30294_photo that is a larger image of the same item. The naming convention is up to you, but it must be consistent. And you'll also need to have other related castmembers with similar names, such as a text member named item30294_description.

You'll need to have specific formatting for the items so that all of the photos are the same dimensions (or at least fit within a defined space). The same goes for anything else displayed on the page; text, for example, should be limited to the available space. Once you've defined these formatting parameters, set up the display frame with placeholders.

For the Lingo part, let's start with the thumbnails page. You'll need to create a button script for the thumbnails that does two things:

  1. It sets a global variable called something like gSelection to a value that designates the selected item. For example, gSelection = "item30294". Since you don't want to have to customize the behavior for each of the thousands of thumbnails, we'll access that value based on the name of the castmember in that sprite.
  2. It does a go to frame "display" -- or whatever you call your display frame.

global gSelection

on mouseUp me
  gSelection = sprite(me.spriteNum)
  go to frame "display"
end mouseUp

A different behavior will be placed on the placeholder sprites in the display frame. That behavior will simply check the global variable gSelection and then dynamically select the corresponding castmembers for the photo, description, and whatever else. We'll put in a field for the "suffix", such as "_photo", that will allow you to use this same behavior for the photo, description and other placeholder sprites.

property pSuffix
global gSelection

on getPropertyDescriptionList me

  pdlist = [:]
  addprop pdlist, #pSuffix, [#comment:"Suffix:", #format:#string, #default:""]

  return pdlist

end getPropertyDescriptionList

on beginSprite me

  mySprite = sprite(me.spriteNum)
  myMemName = gSelection & pSuffix
  mySprite.member = member(myMemName)

end beginSprite

Director 7 download for Mac or Windows.

This same method is quite helpful whenever you find yourself creating any series of pages that are identically formatted and tedious to set up. I've used this approach for quizzes, where the questions and answer selections are dynamically dropped into the page. Good luck with your catalog.

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-2019, Director Online. Article content copyright by respective authors.