ssCore.Mouse.setNotify

Tell SWF Studio about an event that you'd like to receive notifications for.


Availability:

First available in version 3.0 build 2039.


Input Parameters:

event - The event you want to receive notifications for. Valid values include: onMouseMove, onMouseWheel, and onMouseButton.


Output Parameters:

result - Notification data for the specified event (see description of events for more detail).


Asynchronous Mode:

When this method is called asynchronously, a return object containing the output parameters is passed to the specified callback function.

ssCore.Mouse.setNotify( paramsObject [, callbackParamsObject] [, errorParamsObject] );


Synchronous Mode:

When this method is called synchronously, a return object containing the output parameters is returned to the caller immediately.

var returnObject = ssCore.Mouse.setNotify( paramsObject );


Notes:

None.


Events:

name - onMouseMove
type - triggered
result - "x,y,sx,sy"

The onMouseMove event is triggered any time the mouse moves and the data passed to your event handler contains the position of the mouse in two different coordinate systems (window and screen). Your Flash application will receive mouse movement events regardless of where the mouse cursor is.

The first two values in the return data, x and y, are the mouse coordinates (in pixels) relative to the top left corner of the application window. The last two values, sx and sy are the mouse coordinates (in pixels) relative to the top left corner of the desktop.

It is possible for the values of x and y to be negative, these are points to the left of and above the application window. It is also possible for x and y to exceeed the application window size (when the mouse moves past the bottom right corner of the window).

ssCore.Mouse.setNotify({event:"onMouseMove"}, {callback:onMouseMoveEvent});

function onMouseMoveEvent(ret_obj, cb_obj, err_obj)
{
    if (ret_obj.success)
    {
        v = ret_obj.result.split(",");
        ssDebug.trace("mouse x (window): " + v[0]);
        ssDebug.trace("mouse y (window): " + v[1]);
        ssDebug.trace("mouse x (screen): " + v[2]);
        ssDebug.trace("mouse y (screen): " + v[3]);
    }
}

name - onMouseWheel
type - triggered
result - "scroll,keymask,x,y"

The onMouseWheel event is triggered when the scroll wheel on the mouse is moved. The data returned to your event handler contains values that tell you how far the scroll wheel has moved and in what direction as well as the state of the various mouse buttons (or shift keys) and the position of the mouse when the scroll wheel event was generated. Your Flash application will only receive mouse wheel events while the mouse is above the application window.

The scroll value tells you how far the scroll wheel has been moved and in which direction. Positive values are returned when the wheel is scrolled up or away from the user and negative values are returned when the wheel is scrolled down or toward the user.

The keymask value indicates which mouse buttons or shift keys were pressed when the scroll wheel was moved. The keymask can contain any or all of the following characters "LMRSC" where the presence of a letter indicates that the corresponding button or key was pressed while the mouse wheel was being moved. There is no guarantee that these characters will appear in a predictable order, you should check only for the existence of the character in the keymask.

L - the left mouse button was pressed
M - the middle mouse button was pressed
R - the right mouse button was pressed
S - the shift key (left or right) was pressed
C - the control key (left or right) was pressed

The x and y values give you the coordinates (in pixels) of the mouse pointer when the scroll wheel was moved.

ssCore.Mouse.setNotify({event:"onMouseWheel"}, {callback:onMouseWheel});

function onMouseWheel(ret_obj, cb_obj, err_obj)
{
    if (ret_obj.success)
    {
        v = ret_obj.result.split(",");
        ssDebug.trace("scroll: " + v[0]);
        ssDebug.trace("keymask: " + v[1]);
        ssDebug.trace("mouse x: " + v[2]);
        ssDebug.trace("mouse y: " + v[3]);
    }
}

name - onMouseButton
type - triggered
result - "button,state,x,y"

The onMouseButton event is triggered each time a mouse button is pressed. The data received by your event handler contains information about the state of the mouse button as well as the location of the mouse at the time the event was generated. Your Flash application will only receive mouse button events while the mouse is above the application window.

The button value indicates which mouse button was pressed and may contain any one of the following strings "LEFT", "MIDDLE" or "RIGHT". Multiple individual mouse button events will be generated even when it appears that two or more buttons have been pressed at the same time. The order of the UP and DOWN events tell you which button was pressed first.

The state can be "UP", "DOWN" or "DBLCLK" and represents the state of the mouse button. The "UP" state corresponds to Flash onRelease event and the "DOWN" state corresponds to an onPress event. If you don't want to try and figure out when a double click has taken place by timing the up and down states you can just watch for the "DBLCLK" state.

The x and y values provide the coordinates (in pixels) of the mouse pointer when the button was pressed.

ssCore.Mouse.setNotify({event:"onMouseButton"}, {callback:onMouseButton});

function onMouseButton(ret_obj, cb_obj, err_obj)
{
    if (ret_obj.success)
    {
        v = ret_obj.result.split(",");
        ssDebug.trace("button " + v[0]);
        ssDebug.trace("state: " + v[1]);
        ssDebug.trace("mouse x: " + v[2]);
        ssDebug.trace("mouse y: " + v[3]);
    }
}