User Guide

on enterFrame 169
Example
This handler runs when the playhead exits a sprite:
-- Lingo syntax
on endSprite me
-- clean up
gNumberOfSharks = gNumberOfSharks - 1
sound(5).stop()
end
// JavaScript syntax
function endSprite() {
// clean up
gNumberOfSharks--;
sound(5).stop();
}
See also
on beginSprite, on exitFrame
on enterFrame
Usage
-- Lingo syntax
on enterFrame
statement(s)
end
// JavaScript syntax
function enterFrame() {
statement(s);
}
Description
System message and event handler; contains statements that run each time the playhead enters
the frame.
Place
on enterFrame handlers in behavior, frame, or movie scripts, as follows:
To assign the handler to an individual sprite, put the handler in a behavior attached to
the sprite.
To assign the handler to an individual frame, put the handler in the frame script.
To assign the handler to every frame (unless you explicitly instruct the movie otherwise), put
the on enterFrame handler in a movie script. The handler executes every time the playhead
enters a frame unless the frame script has its own handler. If the frame script has its own
handler, the
on enterFrame handler in the frame script overrides the on enterFrame handler
in the movie script.
The order of frame events is
stepFrame, prepareFrame, enterFrame, and exitFrame.
This event is passed the object reference me if used in a behavior.