User Guide

814 ActionScript classes
mouseListener.onMouseWheel = function(delta:Number) {
line_mc._rotation += delta;
};
mouseListener.onMouseDown = function() {
trace("Down");
};
Mouse.addListener(mouseListener);
The MovieClip.getNextHighestDepth() method used in this example requires Flash Player
7 or later. If your SWF file includes a version 2 component, use the version 2 components
DepthManager class instead of the
MovieClip.getNextHighestDepth() method.
See also
addListener (Mouse.addListener method), mouseWheelEnabled
(TextField.mouseWheelEnabled property)
removeListener (Mouse.removeListener method)
public static removeListener(listener:Object) : Boolean
Removes an object that was previously registered with addListener().
Availability: ActionScript 1.0; Flash Player 6
Parameters
listener:Object - An object.
Returns
Boolean - If the listener object is successfully removed, the method returns true; if the
listener is not successfully removed (for example, if the listener was not on the Mouse
object's listener list), the method returns
false.
Example
The following example attaches three buttons to the Stage, and lets the user draw lines in the
SWF file at runtime, using the mouse pointer. One button clears all of the lines from the
SWF file. The second button removes the mouse listener so the user cannot draw lines. The
third button adds the mouse listener after it is removed, so the user can draw lines again. Add
the following ActionScript to Frame 1 of the Timeline:
this.createClassObject(mx.controls.Button, "clear_button",
this.getNextHighestDepth(), {_x:10, _y:10, label:'clear'});
this.createClassObject(mx.controls.Button, "stopDrawing_button",
this.getNextHighestDepth(), {_x:120, _y:10, label:'stop drawing'});
this.createClassObject(mx.controls.Button, "startDrawing_button",
this.getNextHighestDepth(), {_x:230, _y:10, label:'start drawing'});