Accessibility
 
Home > Products > Director > Support > Lingo, Behaviors and Parent Scripts
Macromedia Director Support Center - Lingo, Behaviors and Parent Scripts
Multiple child objects

The movie, "Simple Child Object," is an example of how to create a child object from a parent script. In normal use, you would not use a parent script to create just one child object. You can download and examine a copy of this movie from the links below. See Chapter 12, "Parent Scripts and Child Objects" in the Learning Lingo manual for more details about parent scripts and child objects.

The advantage of parent scripts and child objects comes from their capability to:

Create many child objects on demand as the movie plays. You create a child object each time you issue a new statement.
Share behaviors among related child objects.
Maintain individual and independent property variables for each child object.
The movie, "Multiple Child Objects" shown below, uses Lingo to create similar sets of objects from different parent scripts.

Click New B&W or New Color to make a new ball appear. Click different places on the stage to move the blue paddle and bounce the ball.

Unlike the "Simple Child Object" movie, the "Multiple Child Objects" movie creates more than one child object. Each child object has independent behaviors because it maintains its own property variables. The similarities in the balls—motion and shape—come from an ancestor script that is shared by all the balls. The difference between the balls—color, in this case—comes from the parent script for each related set of balls:

All balls follow the same rules for motion because this characteristic is inherited from the ancestor.
Each ball can have a different velocity, direction, and sprite number because these are property variables. These variables are declared in the ancestor script.
The balls are either color or grayscale, depending on which parent script they have.
See "Creating multiple child objects" of Chapter 12, "Parent Scripts and Child Objects" in the Learning Lingo manual for more details about the scripts in "Multiple Child Objects."

Download the Windows source file for this piece (32K)
Download the Macintosh source file for this piece (96K)

David Benman

Macromedia


data structure, data array, lists, database lists, record list, linear list, complex list, property list

31 October 1997

6845