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:
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 castSwapping 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
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 spriteSemantics 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/castLibNumon a sprite are the raw numeric pair; assigningsprite(n).memberNumswaps the image while keeping the cast.
Universal member properties
| Property | Meaning |
|---|---|
name | Member name (settable). |
number | Global 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, ... |
castLibNum | Owning cast. |
rect | Intrinsic bounding rect (media types). |
regPoint | Registration point (see below). |
width / height | Convenience over rect. |
media | Opaque handle to the member's media data; assignable between members of the same type (fast content swap). |
picture | Legacy image handle (pre-imaging Lingo). |
loaded | TRUE when the media is in memory. |
purgePriority | 0 never, 1 last, 2 next, 3 normal (default): eviction order under memory pressure. |
modified | Changed since load. |
scriptText | Source of attached member script (authoring; empty in protected movies). |
comments, creationDate, modifiedDate, modifiedBy | Metadata. |
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).
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
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").ditherDepth, 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 viafont,fontSize,fontStyle,foreColor. Used for all UI text in bitmap-era games. - Text (
#text): Director 7+ RTF-based, anti-aliased, hyperlinks, kerning,html/rtfproperties.
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
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.