User Guide

on beginSprite 161
See also
activeWindow, close(), on deactivateWindow, frontWindow, on moveWindow, open()
(Window)
on beginSprite
Usage
-- Lingo syntax
on beginSprite
statement(s)
end
// JavaScript syntax
function beginSprite() {
statement(s);
}
Description
System message and event handler; contains statements that run when the playhead moves to a
frame that contains a sprite that was not previously encountered. Like
endSprite, this event is
generated only one time, even if the playhead loops on a frame, since the trigger is a sprite not
previously encountered by the playhead. The event is generated before
prepareFrame.
Director creates instances of any behavior scripts attached to the sprite when the
beginSprite
message is sent.
The object reference
me is passed to this event if it is used in a behavior. The message is sent to
behaviors and frame scripts.
If a sprite begins in the first frame that plays in the movie, the
beginSprite message is sent after
the
prepareMovie message but before the prepareFrame and startMovie messages.
Note: Be aware that some sprite properties, such as the rect sprite property, may not be accessible
in a beginSprite handler. This is because the property needs to be calculated, which is not done until
the sprite is drawn.
The go, play, and updateStage commands are disabled in an on beginSprite handler.
Example
This handler plays the sound cast member Stevie Wonder when the sprite begins:
-- Lingo syntax
on beginSprite me
sound(1).play(member("Stevie Wonder"))
end
// JavaScript syntax
function beginSprite() {
sound(1).play(member("Stevie Wonder"));
}
See also
on endSprite, on prepareFrame, scriptInstanceList