User Guide

872 Chapter 14: Properties
mouseH
Usage
-- Lingo syntax
_mouse.mouseH
// JavaScript syntax
_mouse.mouseH;
Description
Mouse property; indicates the horizontal position of the mouse pointer. Read-only.
The value of
mouseH is the number of pixels the cursor is positioned from the left edge of
the Stage.
The
mouseH property is useful for moving sprites to the horizontal position of the mouse pointer
and checking whether the pointer is within a region of the Stage. Using the
mouseH and mouseV
properties together, you can determine the cursors exact location.
Example
This handler moves sprite 10 to the mouse pointer location and updates the Stage when the user
clicks the mouse button:
-- Lingo syntax
on mouseDown
sprite(10).locH = _mouse.mouseH
sprite(10).locV = _mouse.mouseV
end
// JavaScript syntax
function mouseDown() {
sprite(10).locH = _mouse.mouseH;
sprite(10).locV = _mouse.mouseV;
}
This statement tests whether the pointer is more than 10 pixels to the right or left of a starting
point and, if it is, sets the variable
Far to TRUE:
-- Lingo syntax
startH = 7
if (abs(_mouse.mouseH - startH) > 10) then
Far = TRUE
end if
// JavaScript syntax
var startH = 7;
if (Math.abs(_mouse.mouseH - startH) > 10) {
var Far = true;
}
See also
locH, locV, Mouse, mouseLoc, mouseV