Button events such as onRollOver, onRollOut, onDragOver, onDragOut, onPress, onRelease, onReleaseOutside receive two parameters if Scaleform extensions are on. The first parameter is the zero-based index of mouse that caused the event. Thus, if onPress event was caused by the mouse cursor with an index of 1, then the parameter will contain a value of 1:
mc.onPress = function(mouseIdx:Number) { if (mouseIndex == 0) . . . else if (mouseIndex == 1) . . . . . . }
The second parameter for onPress and onRelease is numeric property that denotes whether the event was caused by a mouse/cursor or keyboard. The value is -1 if keyboard, and 0 if mouse/cursor. This property is useful for determining the source of the events:
mc.onPress = function(mouseIdx:Number, keyboardOrMouse:Number) { if (keyboardOrMouse == 0) . . . else . . . . . . }
The second parameter is optional for onRollOver/Out and onDragOver/Out events. This parameter specifies the index of nested rollover/dragover event over the same character. If this parameter is not declared for the function-handler, then onRollOver/onRollOut and onDragOver/onDragOut event pairs will be fired only once: onRollOver/onDragOver will be fired when the first cursor rolls over the character and onRollOut/onDragOut will be fired when the last cursor leaves it. If the second parameter is declared for these handlers, then nested onRollOver/onRollOut and onDragOver/onDragOut events will be generated (separately for each mouse cursor) and the parameter represents the zero-based index of nesting: the initial onRollOver/onDragOver event will have 0 as the second parameter; if the second cursor rolls over the same character, then the second onRollOver/onRollOut event will be fired with the second parameter set to 1. If any of the cursors leaves the character then the onRollOut/onDragOut will be fired with the second parameter set to 1; the last onRollOut/onDragOut event will be fired with the second parameter set to 0. Thus, the declaration of the second parameter changes the way how the onRollOver/onRollOut and onDragOver/onDragOut events are fired. In the case when the second parameter is declared, it is responsibility of user to take care of nested events.
mc.onRollOver = function(mouseIdx:Number, nestingIdx:Number) { // do roll over animation only if nestingIdx == 0 if (nestingIdx == 0) doOverAnimation(); . . . } mc.onRollOut = function(mouseIdx:Number, nestingIdx:Number) { // do roll out animation only if nestingIdx == 0 if (nestingIdx == 0) doOutAnimation(); . . . }
Note, the old-style events such as on(rollOver), on(rollOut), etc. are not provided with any extra parameters, thus, there is no way to distinguish which mouse cursor caused the event. Thus, they are not recommended to be used with multiple mouse cursors.
To support mouse buttons other than the left button for onPress, onRelease, etc., new auxiliary versions of the Button Events have been added:
These auxiliary event handlers will be invoked if they are defined on the event target. They will only be invoked for buttons with index != 0 (0 index denotes the left mouse button). The regular handlers are always invoked only for the left mouse button, regardless of the existence of the auxiliary event handlers. These handlers also have the same function signature as its standard counterparts, as defined earlier in this section. However, the auxiliary event handlers provide an extra parameter for the button index.
mc.onPressAux = function(mouseIdx:Number, keyboardOrMouse:Number, buttonIdx:Number) { if (buttonIdx == 1) // Right mouse button . . . . . . }