Writing Scripts with Lingo
421
When referring to properties defined in ancestor scripts, you must use the
me
parameter as the
source of the reference. This is because the property, while defined in the ancestor script, is
nevertheless a property of the child object. For example, these statements both use
me
to refer to
an object and access properties defined in an ancestor of the object:
--access ancestor property
x = me.y
or
x = the y of me
Because the
me
variable is present in each handler of the child object, it indicates that all the
handlers control that same child object.
See
me
in the Lingo Dictionary.
Creating a child object
Child objects exist entirely in memory; they are not saved with a movie. Only parent and ancestor
scripts exist on disk.
To create a new child object, you use the
new
function and assign the child object a variable name
or position in a list so you can identify and work with it later.
To create a child object and assign it to a variable, use the syntax:
set
variableName
= new(script "
scriptName
",
argument1
,
argument2
,
argument3
...)
where
scriptName
is the name of the parent script and
argument1
,
argument2
,
argument3
... are
any arguments you are passing to the child object’s
on new
handler.
The
new()
function creates a child object whose ancestor is
scriptName
. It then calls the
on new
handler in the child object with the specified arguments.
You can issue a
new
statement from anywhere in a movie. You can customize the child object’s
initial settings by changing the values of the arguments passed with the
new
statement.
Each child object requires only enough memory to record the current values of its properties and
variables and a reference to the parent script. Because of this, in most cases you can create and
maintain as many child objects as you require.
You can produce additional child objects from the same parent script by issuing additional
new
statements.
To create child objects without immediately initializing their property variables, use the
rawNew()
function. The
rawNew()
function does this by creating the child object without calling the parent
script’s
on new
handler. In situations where large numbers of child objects are needed,
rawNew()
allows you to create the objects ahead of time and defer the assignment of property values until
each object is needed.
This statement creates a child object from the parent script Car without initializing its property
variables and assigns it to the variable
car1
:
car1 = script("Car").rawNew()
To initialize the properties of one of these child objects, call its
on new
handler:
car1.new
Содержание 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...