Writing Scripts with Lingo
419
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.
See
ancestor
in the Lingo Dictionary.
Writing a parent script
A parent script contains the Lingo needed to create child objects and define their possible actions
and properties. First you need to 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. See “Parent
script and child object basics” on page 418.
•
Sets up the initial values of the child objects’ properties and variables in the
on new
handler.
•
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
on new
handler; if it’s not set, the initial value is
VOID
.
To declare a property variable:
•
Use the
property
keyword at the beginning of the parent script. See
property
in the
Lingo Dictionary.
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 Lingo, by
using the syntax
the
propertyName
of
whichObject
or
whichObject.propertyName
.
This statement sets the
speed
property of the object
car1
:
car1.speed = 55
Содержание DIRECTOR MX-USING DIRECTOR MX
Страница 1: ...Using Director MX Macromedia Director MX...
Страница 12: ...Contents 12...
Страница 156: ...Chapter 4 156...
Страница 202: ...Chapter 6 202...
Страница 244: ...Chapter 7 244...
Страница 292: ...Chapter 10 292...
Страница 330: ...Chapter 12 330...
Страница 356: ...Chapter 13 356...
Страница 372: ...Chapter 14 372...
Страница 442: ...Chapter 16 442...
Страница 472: ...Chapter 18 472...
Страница 520: ...Chapter 19 520...
Страница 536: ...Chapter 20 536...
Страница 562: ...Chapter 23 562...
Страница 566: ...Chapter 24 566...
Страница 602: ...Chapter 27 602...