182
Chapter 10: Events and Messages
When the mouse button is pressed, Lingo searches the following locations, in order, for an
on
mouseDown
handler: primary event handler, sprite script, cast member script, frame script, and
movie script. Lingo stops searching when it reaches the first location that has an
on mouseDown
handler, unless the handler includes the
pass
command to explicitly pass the
mouseDown
message
on to the next location.
To have the same response throughout the movie when pressing the mouse button, set
mouseDownScript
or put a mouseDown handler in a Movie script.
The
on mouseDown
event handler is a good place to put Lingo that flashes images, triggers sound
effects, or makes sprites move when the user presses the mouse button.
Where you place an
on mouseDown
handler can affect when it runs.
•
To apply the handler to a specific sprite, put it in a sprite script.
•
To apply the handler to a cast member in general, put it in a cast member script.
•
To apply the handler to an entire frame, put it in a frame script.
•
To apply the handler throughout the entire movie, put it in a movie script.
You can override an
on mouseDown
handler by placing an alternative
on mouseDown
handler in a
location that Lingo checks before it gets to the handler you want to override. For example, you
can override an
on mouseDown
handler assigned to a cast member by placing an
on mouseDown
handler in a sprite script.
If used in a behavior, this event is passed the sprite script or frame script reference
me
.
Example
This handler checks whether the user clicks anywhere on the Stage and sends the playhead to
another frame if a click occurs:
-- Lingo syntax
on mouseDown
if (_mouse.clickOn = 0) then _movie.go("AddSum")
end
// JavaScript syntax
function mouseDown() {
if (_mouse.clickOn == 0) {
_movie.go("AddSum");
}
}
This handler, assigned to a sprite script, plays a sound when the sprite is clicked:
-- Lingo syntax
on mouseDown
sound(1).play(member("Crickets"))
end
// JavaScript syntax
function mouseDown() {
sound(1).play(member("Crickets"));
}
See also
clickOn
,
mouseDownScript
,
mouseUpScript
Summary of Contents for DIRECTOR MX 2004-DIRECTOR SCRIPTING
Page 1: ...DIRECTOR MX 2004 Director Scripting Reference...
Page 48: ...48 Chapter 2 Director Scripting Essentials...
Page 100: ...100 Chapter 4 Debugging Scripts in Director...
Page 118: ...118 Chapter 5 Director Core Objects...
Page 594: ...594 Chapter 12 Methods...
Page 684: ...684 Chapter 14 Properties See also DVD...
Page 702: ...702 Chapter 14 Properties See also face vertices vertices flat...
Page 856: ...856 Chapter 14 Properties JavaScript syntax sprite 15 member member 3 4...
Page 1102: ...1102 Chapter 14 Properties...