Syntax
onEnterFrame() {
statement(s);
}
Arguments
None.
Returns
Nothing.
Description
This Event Handler Function is called at the start of each Frame. The Actions associated with the Event are processed before any Frame Actions that are attached to the affected Frames.
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 = _root.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 Object is released, stop mouse drag
}