
new()
417
For cast members, the
type
parameter sets the cast member’s type. Possible predefined values
correspond to the existing cast member types:
#bitmap
,
#field
, and so on. The
new
function can
also create Xtra cast member types, which can be identified by any name that the author chooses.
It’s also possible to create a new color cursor cast member using the Custom Cursor Xtra. Use
new(#cursor)
and set the properties of the resulting cast member to make them available for use.
The optional
whichCastMember
and
whichCast
parameters specify the cast member slot and
Cast window where the new cast member is stored. When no cast member slot is specified, the
first empty slot is used. The
new
function returns the cast member slot.
When the argument for the
new
function is a parent script, the
new
function creates a
child object. The parent script should include an
on new
handler that sets the child object’s initial
state or property values and returns the
me
reference to the child object.
The child object has all the handlers of the parent script. The child object also has the same
property variable names that are declared in the parent script, but each child object has its own
values for these properties.
Because a child object is a value, it can be assigned to variables, placed in lists, and passed
as a parameter.
As with other variables, you can use the
put
command to display information about a child object
in the Message window.
When
new()
is used to create a timeout object, the timeoutPeriod sets the number of milliseconds
between timeout events sent by the timeout object. The
#timeoutHandler
is a symbol that
identifies the handler that will be called when each timeout event occurs. The
targetObject
identifies the name of the child object that contains the
#timeoutHandler
. If no
targetObject
is given, the
#timeoutHandler
is assumed to be in a movie script. The timeout creation syntax
might vary depending on the
scriptExecutionStyle
setting.
-- Lingo syntax when scriptExecutionStyle is set to 9
x = timeout(name).new(period,handler,targetData)
-- Lingo syntax when scriptExecutionStyle is set to 10
x = timeout().new(name, period, handler, targetData)
y = new timeout(name, period, handler, targetData)
// JavaScript syntax
x = new timeout(name, period, function, targetData)
When a timeout object is created, it enables its
targetObject
to receive the system events
prepareMovie
,
startMovie
,
stopMovie
,
prepareFrame
, and
exitFrame
. To take advantage of
this, the
targetObject
must contain handlers for these events. The events do not need to be
passed in order for the rest of the movie to have access to them.
Note:
A Lingo-created timeout object can call a JavaScript syntax function, and vice versa.
To see an example of
new()
used in a completed movie, see the Parent Scripts, and Read and
Write Text movies in the Learning/Lingo folder inside the Director application folder.
Example
To create a new bitmap cast member in the first available slot, you use this syntax:
set newMember = new(#bitmap)
Содержание 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...