180
Chapter 10: Events and Messages
You can override an
on keyDown
handler by placing an alternative
on keyDown
handler in a
location that Lingo checks before it gets to the handler you want to override. For example, you
can override an
on keyDown
handler assigned to a cast member by placing an
on keyDown
handler in a sprite script.
Example
This handler checks whether the Return key was pressed and if it was, sends the playhead to
another frame:
-- Lingo syntax
on keyDown
if (_key.key = RETURN) then _movie.go("AddSum")
end keyDown
// JavaScript syntax
function keyDown() {
if (_key.keyCode == 36) {
_movie.go("AddSum");
}
}
See also
charToNum()
,
keyDownScript
,
keyUpScript
,
key
,
keyCode
,
keyPressed()
on keyUp
Usage
-- Lingo syntax
on keyUp
statement(s)
end
// JavaScript syntax
function keyUp() {
statement(s);
}
Description
System message and event handler; contains statements that run when a key is released. The
on
keyUp
handler is similar to the
on keyDown
handler, except this event occurs after a character
appears if a field or text sprite is editable on the screen.
When a key is released, Lingo searches these locations, in order, for an
on keyUp
handler: primary
event handler, editable field sprite script, field cast member script, frame script, and movie script.
For sprites and cast members,
on keyUp
handlers work only for editable strings. A
keyUp
event on
a different type of cast member, such as a bitmap, has no effect. If releasing a key should always
have the same response throughout the movie, set
keyUpScript
.
Lingo stops searching when it reaches the first location that has an
on keyUp
handler, unless the
handler includes the
pass
command to explicitly pass the
keyUp
message on to the next location.
The
on keyUp
event handler is a good place to put Lingo that implements keyboard shortcuts or
other interface features that you want to occur when the user releases keys.
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...