SWiSH Player Support
SWF4 or later - Supported Internally
Syntax
onEnterFrame() {
statement(s);
}
onEnterFrame(includingFirstFrame) {
statement(s);
}
onEnterFrame(excludingFirstFrame) {
statement(s);
}
Arguments
includingFirstFrame: Optional keyword. see below
excludingFirstFrame: Optional keyword. See below.
Returns
Nothing.
Description
This Event Handler Function is called at the start of each frame of display, whether the associated object is playing or not. However, if the sprite is removed, then the onEnterFrame actions are no longer processed. The Actions associated with the Event are processed before any Frame Action events for the object.
If "includingFirstFrame" is specified, then the actions will be processed on all frames of display starting from and including the very first frame that the object is placed. If "excludingFirstFrame" is specified, then it will not run for the first time until the frame AFTER the object is placed. Compare this with the onLoad Event Handler Function, which will run ONLY for the first frame of display.
The default if you specify neither option is "excludingFirstFrame" (this is the same behaviour as Flash uses for its enterFrame clip event).
This Event Handler is an ideal place to install collision detection routines for games, etc.
Sample
s1, s2 are both Sprites. Below is the scripting for Sprite s1. Debug trace is generated on transition.
onEnterFrame() {
blIsNear = _parent.s2.isNearThis();
if (blIsNear != blIsNearLast) {
// we have moved to or from is Near condition
trace("x=" + _X + " y=" + _Y + " isnear=" + blIsNear);
}
blIsNearLast = blIsNear;
}
onLoad () {
blIsNearLast = false; // initialise boundary condition
}
onSelfEvent (press) {
this.startDragLocked(); // when object is clicked on, start mouse drag
}
onSelfEvent (release) {
stopDrag(); // when mouse is released, stop mouse drag
}