500
Chapter 12: Methods
registerForEvent()
Usage
member(
whichCastmember
).registerForEvent(
eventName
, \
handlerName
,
scriptObject
{,
begin, period
,
repetitions
})
Description
3D command; declares the specified handler as the handler to be called when the specified event
occurs within the specified cast member.
The following parameter descriptions apply to both the
registerForEvent()
and the
registerScript()
commands.
Note:
You can associate the registration of a script with a particular node rather than with a cast
member by using the
registerScript()
command.
Parameters
eventName
Required. Specifies the name of the event. The event can be any of the following
predefined events, or any custom event that you define:
•
#collideAny
is a collision event.
•
#collideWith
is a collision event involving this specific model. The
setCollisionCallback()
command is a shortcut for using the
registerScript()
command for the
#collideWith
event.
•
#animationStarted
and
#animationEnded
are notification events that occur when a bones
or keyframe animation starts or stops playing. The handler will receive three arguments:
eventName
,
motion
, and
time
. The
eventName
argument is either
#animationStarted
or
#animationEnded
. The
motion
argument is the name of the motion that has started or
stopped playing, and
time
is the current time of the motion.
•
For looping animations, the
#animationStarted
event is issued only for the first loop, not
for subsequent loops. During a blend of two animations, this event will be sent when the
blending begins.
•
When a series of animations is queued for the model and the animation’s
autoBlend
property
is set to
TRUE
, the
#animationEnded
event may occur before the apparent end of a given
motion. This is because the
autoBlend
property may make the motion appear to continue
even though the animation has completed as defined.
•
#timeMS
is a time event. The first
#timeMS
event occurs when the number of milliseconds
specified in the
begin
parameter have elapsed after
registerForEvent
is called. The
period
parameter determines the number of milliseconds between
#timeMS
events when the value of
repetitions
is greater then 0. If
repetitions
is 0, the
#timeMS
event occurs indefinitely.
handlerName
Required. Specifies the name of the handler that will be called when the event
eventName
occurs; this handler is found in the script object indicated by
scriptObject
. The
handler is sent the following arguments:
•
type
is always 0.
•
delta
is the elapsed time in milliseconds since the last
#timeMS
event.
•
time
is the number of milliseconds since the first
#timeMS
event occurred. For example, if
there are three iterations with a period of 500 ms, the first iteration’s time will be 0, the second
iteration will be 500, and the third will be 1000.
Summary of Contents for DIRECTOR MX 2004-DIRECTOR SCRIPTING
Page 1: ...DIRECTOR MX 2004 Director Scripting Reference...
Page 48: ...48 Chapter 2 Director Scripting Essentials...
Page 100: ...100 Chapter 4 Debugging Scripts in Director...
Page 118: ...118 Chapter 5 Director Core Objects...
Page 594: ...594 Chapter 12 Methods...
Page 684: ...684 Chapter 14 Properties See also DVD...
Page 702: ...702 Chapter 14 Properties See also face vertices vertices flat...
Page 856: ...856 Chapter 14 Properties JavaScript syntax sprite 15 member member 3 4...
Page 1102: ...1102 Chapter 14 Properties...