MACROMEDIA DIRECTOR MX-USING DIRECTOR MX Use Manual page 418

Table of Contents

Advertisement

Parent script and child object basics
A parent script is a set of handlers and properties that define a child object; it is not a child object
itself. A child object is a self-contained, independent instance of a parent script. Children of the
same parent have identical handlers and properties, so child objects in the same group can have
similar responses to events and messages.
Typically, parent scripts are used to build child objects that make it easier to organize movie logic.
These child objects are especially useful when a movie requires the same logic to be run several
times concurrently with different parameters. You can also add a child object to a sprite's
scriptInstanceList
Because all the child objects of the same parent script have identical handlers, those child objects
respond to events in similar ways. However, because each child object maintains independent
values for the properties defined in the parent script, each child object can behave differently than
its sibling objects—even though they are instances of the same parent script.
For example, you can create a parent script that defines child objects that are editable text fields,
each with its own property settings, text, and color, regardless of the other text fields' settings.
By changing the values of properties in specific child objects, you can change any of these
characteristics as the movie plays without affecting the other child objects based on the
same parent script.
Similarly, a child object can have a property set to either
property's setting in sibling child objects.
Differences between child objects and behaviors
While child objects and behaviors are similar in that they both can have multiple instances, they
have some important differences as well. The main difference between child objects and behaviors
is that behaviors are associated with locations in the Score because they are attached to sprites.
Behavior objects are automatically created from initializers stored in the Score as the playhead
moves from frame to frame and encounters sprites with attached behaviors. In contrast, child
objects from parent scripts must be created explicitly by a handler.
Behaviors and child objects differ in how they become associated with sprites. Director
automatically associates a behavior with the sprite that the behavior is attached to, but you must
explicitly associate a child object with a sprite. Child objects don't require sprite references and
exist only in memory.
Ancestor basics
Parent scripts can declare ancestors, which are additional scripts whose handlers and properties a
child object can call on and use.
Ancestor scripting lets you create a set of handlers and properties that you can use and reuse for
multiple parent scripts.
A parent script makes another parent script its ancestor by assigning the script to its
property. For example, the following statement makes the script What_Everyone_Does an
ancestor to the parent script in which the statement occurs:
set ancestor to new(script "What_Everyone_Does")
418
Chapter 16
or the
as a way to control animation.
actorList
or
regardless of that
TRUE
FALSE
ancestor

Advertisement

Table of Contents
loading

This manual is also suitable for:

Director mx

Table of Contents