632
Chapter 14: Properties
For child objects, the
ancestor
property is usually assigned in the
on new
handler within the
parent script. Sending a message to a child object that does not have a defined handler forwards
that message to the script defined by the
ancestor
property.
If a behavior has an ancestor, the ancestor receives mouse events such as
mouseDown
and
mouseWithin
.
The
ancestor
property lets you change behaviors and properties for a large group of objects with
a single command.
The ancestor script can contain independent property variables that can be obtained by child
objects. To refer to property variables within the ancestor script, you must use this syntax:
me.
propertyVariable =
value
For example, this statement changes the property variable
legCount
within an ancestor script
to 4:
me.legCount = 4
Use the syntax
the
variableName
of
scriptName
to access property variables that are not
contained within the current object. This statement allows the variable
myLegCount
within the
child object to access the property variable
legCount
within the ancestor script:
set myLegCount to the legCount of me
Example
Each of the following scripts is a cast member. The ancestor script Animal and the parent scripts
Dog and Man interact with one another to define objects.
The first script, Dog, sets the property variable
breed
to Mutt, sets
the
ancestor of Dog
to the
Animal script, and sets the
legCount
variable that is stored in the ancestor script to 4:
property breed, ancestor
on new me
set breed = "Mutt"
set the ancestor of me to new(script "Animal")
set the legCount of me to 4
return me
end
The second script, Man, sets the property variable
race
to Caucasian, sets
the ancestor of Man
to the Animal script, and sets the
legCount
variable that is stored in the ancestor script to 2:
property race, ancestor
on new me
set race to "Caucasian"
set the ancestor of me to new(script "Animal")
set the legCount of me to 2
return me
end
See also
new()
,
me
,
property
Содержание DIRECTOR MX 2004-DIRECTOR SCRIPTING
Страница 1: ...DIRECTOR MX 2004 Director Scripting Reference...
Страница 48: ...48 Chapter 2 Director Scripting Essentials...
Страница 100: ...100 Chapter 4 Debugging Scripts in Director...
Страница 118: ...118 Chapter 5 Director Core Objects...
Страница 594: ...594 Chapter 12 Methods...
Страница 684: ...684 Chapter 14 Properties See also DVD...
Страница 702: ...702 Chapter 14 Properties See also face vertices vertices flat...
Страница 856: ...856 Chapter 14 Properties JavaScript syntax sprite 15 member member 3 4...
Страница 889: ...netPresent 889 _player alert Sorry the Network Support Xtras could not be found See also Player...
Страница 1102: ...1102 Chapter 14 Properties...