480 Chapter 12: ActionScript Dictionary
Listeners enable different pieces of code to cooperate because multiple listeners can receive
notification about a single event.
See also
Mouse.addListener()
Mouse.onMouseWheel
Availability
Flash Player 7 (Windows only).
Usage
someListener.onMouseWheel = function ( [ delta , scrollTarget ]) {
// your statements here
}
Parameters
delta
An optional number indicating how many lines should be scrolled for each notch the
user rolls the mouse wheel. A positive
delta value indicates an upward scroll; a negative value
indicates a downward scroll. Typical values are from 1 to 3, whereas faster scrolling may produce
larger values.
If you don’t want to specify a value for
delta but want to specify a value for scrollTarget, pass
null for delta.
scrollTarget The topmost movie clip instance under the mouse when the mouse wheel
was scrolled.
Returns
Nothing.
Description
Listener; notified when the user rolls the mouse wheel. To use the onMouseWheel listener, you
must create a listener object. You can then define a function for
onMouseWheel and use
addListener() to register the listener with the Mouse object.
Note: Mouse wheel event listeners are available only on Windows versions of Flash Player.
Example
The following example shows how to create a listener object that responds to mouse wheel events.
In this example, the x coordinate of a movie clip object named
clip_mc (not shown) is changed
each time the user rolls the mouse wheel.
mouseListener = new Object();
mouseListener.onMouseWheel = function(delta) {
clip_mc._x += delta;
}
Mouse.addListener(mouseListener);
See also
Mouse.addListener()
, TextField.mouseWheelEnabled