DDirectorWikiDirector & Lingo Encyclopedia

Casts and Cast Members

Cast libraries, member lookup by name and number, member properties, member types, and runtime member creation.

Cast libraries

A movie has one internal cast and any number of external casts (.cst/.cxt/.cct). Casts are addressed by number or name:

lingo
castLib(1)                      -- first cast
castLib("ui")                   -- by name
the number of castLibs
castLib("ui").fileName          -- external cast file path (settable at runtime!)
castLib("ui").member(3)         -- member access scoped to one cast

Swapping fileName at runtime is how Habbo-style clients hot-load room and furniture casts: assign a new file to a placeholder castLib and its members appear under the same library number.

Member references

lingo
m = member("bmpTree")                -- search ALL casts by name (first match wins)
m = member("bmpTree", "scenery")     -- name + cast name
m = member(12)                       -- member 12 of castLib 1
m = member(12, 3)                    -- member 12 of castLib 3
m = sprite(5).member                 -- from a sprite

Semantics to preserve exactly:

  • Name lookup searches casts in order (castLib 1 first) and returns the first name match. Duplicate names across casts are common; load order therefore matters.
  • Name lookup is case-insensitive.
  • Number lookup is positional within one cast and fast; name lookup is a search and slower (real movies cache member refs in globals for hot paths).
  • A reference to an empty slot is valid (member(999) returns a member object of type #empty); erroring on it breaks content.
  • memberNum/castLibNum on a sprite are the raw numeric pair; assigning sprite(n).memberNum swaps the image while keeping the cast.

Universal member properties

PropertyMeaning
nameMember name (settable).
numberGlobal member number (encodes castLib in the high bits for multi-cast movies; member(n) accepts it).
type#bitmap, #field, #text, #sound, #script, #shape, #filmLoop, #digitalVideo, #flash, #vectorShape, #palette, #font, #cursor, #button, #empty, ...
castLibNumOwning cast.
rectIntrinsic bounding rect (media types).
regPointRegistration point (see below).
width / heightConvenience over rect.
mediaOpaque handle to the member's media data; assignable between members of the same type (fast content swap).
pictureLegacy image handle (pre-imaging Lingo).
loadedTRUE when the media is in memory.
purgePriority0 never, 1 last, 2 next, 3 normal (default): eviction order under memory pressure.
modifiedChanged since load.
scriptTextSource of attached member script (authoring; empty in protected movies).
comments, creationDate, modifiedDate, modifiedByMetadata.

The registration point

regPoint is the member-space pixel that a sprite's loc positions on stage. Default is the media center for bitmaps (and the topLeft for text/fields). Changing regPoint shifts every sprite using the member. Sprite loc = stage position of regPoint; sprite rect = member rect translated so regPoint lands at loc (then stretched if the sprite is resized).

lingo
member("tree").regPoint = point(16, 62)   -- anchor at trunk base
sprite(5).loc = point(200, 300)           -- trunk base now at (200,300)

Isometric games position everything through regPoints; a one-pixel regPoint error misaligns an entire room. Emulators must apply regPoint before stretch/flip transforms.

Type-specific highlights

Bitmap members

lingo
member("photo").image              -- imaging Lingo surface (D8+)
member("photo").depth              -- 1/2/4/8/16/32
member("photo").palette            -- palette member ref or built-in symbol
member("photo").useAlpha           -- respect 32-bit alpha channel
member("photo").alphaThreshold     -- hit-test alpha cutoff
member("photo").dither

Depth, palette, and useAlpha interact with ink compositing; see Bitmaps, palettes, and imaging and Ink modes.

Field vs Text members

Two different text systems:

  • Field (#field): classic bitmap-font text, cheap, editable, single-byte, styled per chunk via font, fontSize, fontStyle, foreColor. Used for all UI text in bitmap-era games.
  • Text (#text): Director 7+ RTF-based, anti-aliased, hyperlinks, kerning, html/rtf properties.

Both expose text, chunk-addressable content, editable, wordWrap, alignment, and scrolling (scrollTop, scrollByLine). Measurement APIs (charPosToLoc, locToCharPos, lineHeight etc.) differ subtly between the two; see Text and fields.

Script members

member(n).scriptType is #movie, #score, or #parent. The compiled handlers are the runtime payload; script("name") returns the script object for new().

Sound members

Internal (embedded) or linked (external file); loop, preLoadTime, cue points for synchronization.

Creating and destroying members at runtime

lingo
new(#bitmap)                          -- create in first free slot
newMember = _movie.newMember(#text)   -- MX 2004 form
newMember.name = "generated"
member("generated").erase()           -- delete media, slot becomes #empty
duplicate(member("a"), member(300))   -- copy into slot 300
importFileInto member(300), "photo.jpg"

Runtime member creation is heavily used by dynamic UIs (chat bubbles, generated buttons, camera photos). Generated members behave identically to authored ones, including in name lookup, which is why emulators must implement live cast mutation, not a read-only asset table.

Memory model

Members load lazily (on first need) unless preloaded, and unload according to purgePriority under pressure. preLoad/preLoadMember/unLoad/unLoadMember give manual control; the memorySize, freeBytes(), ramNeeded() observe it. Details in Memory and streaming.