MACROMEDIA DIRECTOR MX 2004-DIRECTOR SCRIPTING Reference page 57

Director scripting reference
Table of Contents

Advertisement

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:
-- Lingo syntax
ancestor = new(script "What_Everyone_Does")
When handlers and properties are not defined in a child object, Director searches for the handler
or property in the child's ancestors, starting with the child's parent script. If a handler is called or
a property is tested and the parent script contains no definition for it, Director searches for a
definition in the ancestor script. If a definition exists in the ancestor script, that definition is used.
A child object can have only one ancestor at a time, but that ancestor script can have its own
ancestor, which can also have an ancestor, and so on. This lets you create a series of parent scripts
whose handlers are available to a child object.
Writing a parent script
A parent script contains the code needed to create child objects and define their possible actions
and properties. First, you must decide how you want the child objects to behave. Then, you can
write a parent script that does the following:
Optionally declares any appropriate property variables; these variables represent properties for
which each child object can contain a value independent of other child objects.
Sets up the initial values of the child objects' properties and variables in the
Contains additional handlers that control the child objects' actions.
Declaring property variables
Each child object created from the same parent script initially contains the same values for its
property variables. A property variable's value belongs only to the child object it's associated with.
Each property variable and its value persists as long as the child object exists. The initial value for
the property variable is typically set in the
To declare a property variable:
Use the
property
To set and test property variables from outside the child object:
Set and test property variables in the same way you would any other property in your scripts,
by using the syntax
For example, the following statement sets the
car1.speed = 55
Creating the new handler
Each parent script typically uses an
when another script issues a
specified parent script to create a child object from itself. The
can also set the child object's initial property values, if you want.
The
handler always starts with the phrase
on new
parameters being passed to the new child object.
on new
keyword at the beginning of the parent script.
objectRef.propertyName
on new
new(script parentScriptName)
handler; if it's not set, the initial value is
.
property of an object
speed
handler. This handler creates the new child object
command, which tells the
on new
followed by the
on new,
Object-oriented programming with Lingo
ancestor
handler.
on new
VOID
:
car1
handler in the parent script
variable and any
me
.
57

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the DIRECTOR MX 2004-DIRECTOR SCRIPTING and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Director mx 2004

Table of Contents