There are two
onClipEvent()
actions in the
onClipEvent(load)
actions in the
onClipEvent(enterFrame)
frame. Even in a one-frame SWF file, the playhead still enters that frame repeatedly and the script
executes repeatedly. The following actions occur within each
onClipEvent(load)
positions of the
movie clip instance. A function is defined and assigned to the
bug
event of the Reset instance. This function is called each time the mouse button is pressed and
released on the Reset button. The function places the ladybug back in its starting position on the
Stage, resets its rotation and alpha values, and resets the
onClipEvent(enterFrame)
whether the bug instance is touching the outlet instance (
outcomes of the evaluation,
onClipEvent (load) {
initx = _x;
inity = _y;
_root.Reset.onRelease = function() {
zapped = false;
_x = initx;
_y = inity;
_alpha = 100
_rotation = 0;
};
}
If the
method returns
hitTest()
set to
, the alpha and rotation properties are changed, and the
true
If the
method returns
hitTest()
immediately following the
There are two
handlers attached to the
on()
. The actions in the
release
the
instance. The actions in the
bug
released over the
instance. The following actions occur within each
bug
on(press)
A
startDrag()
the
instance, the keyword
bug
on (press) {
this.startDrag();
}
on(release)
A
stopDrag()
on (release) {
stopDrag();
}
To watch the SWF file play, see ActionScript Reference Guide Help.
handlers with two different events:
statement execute only once, when the SWF file loads. The
statement execute every time the playhead enters a
Two variables,
and
initx
A conditional
or
:
true
false
, the
true
, none of the code within the curly braces (
false
statement runs.
if
statement execute when the mouse button is pressed over
on(press)
on(release)
action makes the ladybug draggable. Because the script is attached to
indicates that it is the
this
action stops the drag action:
onClipEvent()
, are defined to store the initial x and y
inity
variable to
zapped
statement uses the
if
_root.zapper
method is called, the
stopDrag()
instance with two different events:
bug
statement execute when the mouse button is
instance that is draggable:
bug
Deconstructing a sample script
and
load
enterFrame
handler:
onRelease
.
false
method to check
hitTest()
). There are two possible
variable is
zapper
instance is told to play.
zapped
)
{}
press
onClipEvent()
. The
and
handler:
109
Need help?
Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?
Questions and answers