Mouse related UI functions.
Properties
x |
The current x position of the mouse relative to the top left of the player window. |
y |
The current y position of the mouse relative to the top left of the player window. |
button |
An integer value representing which mouse buttons are down (1=left, 2=right, 3=left+right, etc). |
autoCursor |
Boolean value that determines whether the system should set the cursor automatically (defaults to true). |
cursor |
String value representing the current cursor. e.g. one of the built in cursor types "default","hand","wait". You can also change this to your own embedded .cur or .ani cursor file, which should be placed in the document's top level resources. |
inWindow |
Returns true if the mouse is in the player window. |
Detailed information on a mouse hit. |
Methods
show() |
Shows the mouse cursor. |
hide() |
String value representing the current cursor. e.g. "default","hand","wait". |
trap() |
Traps the mouse within the player window. If focus is lost with the trap set, the trap is temporarily removed until focus is returned. |
untrap() |
Releases the mouse from being trapped. |
simulateClick(x,y) |
Simulates a mouse click at the x,y position. |
getLayerIds() |
Returns an array of string identifiers of all layers the mouse is currently over. |
Built in Cursors
Built in cursor types are: pointer, hand, ibeam, wait, cross, uparrow, size, icon, sizenwse, sizenesw, sizewe, sizens, sizeall, no, appstarting, help.
Examples
print("Mouse x position is: "+system.ui.mouse.x);
system.ui.mouse.cursor="mycursor.ani"; // set cursor to custom mycursor.ani located in the document level resources.
// Check which buttons are down
function onUpdate()
{
for(var buttonIndex=0;buttonIndex<31;buttonIndex++)
{
if (system.ui.joystick.button & Math.pow(2,buttonIndex))
{
print("Button "+buttonIndex+" is down");
}
}
}
Remarks
All mouse x/y coordinates are in pixels.
See Also


