
MovieClip.onMouseDown() Event Handler
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
686
|
ActionScript Language Reference
The .fla file for this example is available at the online Code Depot:
// Attach this onLoad() handler to a clip named star0
onClipEvent (load) {
// Place the current clip at a random position
_x = Math.floor(Math.random() * 550);
_y = Math.floor(Math.random() * 400);
// Reset clip scale so we don't inherit previous clip's scale
_xscale = 100;
_yscale = 100;
// Randomly size current clip between 50 and 150 percent
randScale = Math.floor(Math.random() * 100) - 50;
_xscale += randScale;
_yscale += randScale;
// If we're not at the 100th star, make another one
if (_name != "star100") {
nextStarNumber = Number(_name.substring(4, _name.length)) + 1;
this.duplicateMovieClip("star" + nextStarNumber, nextStarNumber);
}
}
MovieClip.onMouseDown() Event Handler
handler executed when primary mouse button is depressed while the clip is on stage
Flash 5; callback form introduced in Flash 6
mc.onMouseDown()
onClipEvent (mouseDown) {
statements
}
Description
The onMouseDown() event handler is the callback form (and more modern analogue) of
the legacy onClipEvent (mouseDown) event handler. The onMouseDown() event handler is
identical to the Mouse.onMouseDown() listener event, except that it allows for screen
refreshes between frames ...