
Checking keys with Lingo or JavaScript syntax
297
•
To set up script that runs when the mouse pointer is within a sprite’s bounding rectangle when
the playhead enters the frame that contains the sprite, place the script in an
on mouseWithin
event handler.
The
mouseWithin
event can occur repeatedly as long as the mouse pointer remains
inside the sprite.
•
To determine whether the cursor is over a specific sprite, use the
rollOver()
method.
Finding mouse pointer locations with Lingo or JavaScript syntax
Determining where the mouse pointer is on the Stage is a common need in Director.
To determine the mouse pointer’s horizontal and vertical positions:
•
Use the
mouseH
and
mouseV
properties. For more information about these properties, see the
Scripting Reference topics in the Director Help Panel.
The
mouseV
property returns the distance, in pixels, between the mouse pointer and the upper-
left corner of the Stage. The
mouseH
property returns the distance, in pixels, between the mouse
pointer and the upper left corner of the Stage.
The statements
put the mouseH
and
put the mouseV
display the mouse pointer’s location in
the Message window.
For example, this handler directs the Message window to display the distance (in pixels) between
the pointer and the upper left corner of the Stage:
on exitFrame
put(_mouse.mouseH)
put(_mouse.mouseV)
_movie.go(_movie.frame)
end
Checking keys with Lingo or JavaScript syntax
Lingo or JavaScript syntax can detect the last key that the user pressed. For more information, see
the Scripting Reference topics in the Director Help Panel.
•
To obtain the ANSI value of the last key that was pressed, use the
key
property.
•
To obtain the keyboard’s numerical (or ASCII) value for the last key pressed, use the
keyCode
property.
A common place for using
key
and
keyCode
is in an
on keyDown
handler, which instructs the
script to check the value of
key
only when a key is actually pressed. For example, the following
handler in a frame script sends the playhead to the next marker whenever the user presses Enter
(Windows) or Return (Macintosh):
on keyDown
if the key = RETURN then go to marker (1)
end
Summary of Contents for DIRECTOR MX 2004-USING DIRECTOR
Page 1: ...DIRECTOR MX 2004 Using Director...
Page 16: ...16 Chapter 1 Introduction...
Page 82: ...82 Chapter 3 Sprites...
Page 98: ...98 Chapter 4 Animation...
Page 134: ...134 Chapter 5 Bitmaps...
Page 242: ...242 Chapter 10 Sound and Synchronization...
Page 274: ...274 Chapter 11 Using Digital Video...
Page 290: ...290 Chapter 12 Behaviors...
Page 302: ...302 Chapter 13 Navigation and User Interaction...
Page 334: ...334 Chapter 15 The 3D Cast Member 3D Text and 3D Behaviors...
Page 392: ...392 Chapter 16 Working with Models and Model Resources...
Page 418: ...418 Chapter 18 Movies in a Window...
Page 446: ...446 Chapter 22 Managing and Testing Director Projects...