finding the name of a parent script
parent script name

  the name of a parent script
> Given a child object, is there a way to determine the name of the parent
> script cast member from which it was instanced?

Here's the traditional D7 way:

-- Welcome to Director --
obj = script("parent script").new()

the itemDelimiter = QUOTE

put string(obj.string.item[2])
-- "parent script"

However in D8 there are new methods for finding out things about a script:

1. obj.script - this returns a script reference for the parent script
2. obj.handlers() - returns a list of handlers in the object
3. obj.handler(#name) - returns true if the handler is in the object
4. script.rawNew() - instances a parent script without calling new

Cool stuff for lingo geeks like me. :-)

For example if I want to duplicate an object I can use this simple handler:

on clone child

  parent = child.script
  clone = parent.rawNew()

  numProps = count(child)
  repeat with i = 1 to numProps
    propName = child.getPropAt(i)
    propValue = child[i]
    clone[propName] = propValue
  end repeat

  return clone


This only performs a shallow copy - any references that are stored in a
property will point to the same list, ancestor, etc. To make a 'deep' copy
of an object then check the ilk of the property value and duplicate

Home shock + cgi Bits 'n pieces Director Lingo ShockLets Contact