User Guide
Mouse 437
Example
The following example uses the mouse pointer as a tool to draw lines using
onMouseMove and
the Drawing API. The user draws a line by moving the pointer and stops drawing the line by
releasing the mouse button.
this.createEmptyMovieClip("canvas_mc", this.getNextHighestDepth());
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function() {
this.isDrawing = true;
canvas_mc.lineStyle(2, 0xFF0000, 100);
canvas_mc.moveTo(_xmouse, _ymouse);
};
mouseListener.onMouseMove = function() {
if (this.isDrawing) {
canvas_mc.lineTo(_xmouse, _ymouse);
}
updateAfterEvent();
};
mouseListener.onMouseUp = function() {
this.isDrawing = false;
};
Mouse.addListener(mouseListener);
See also
addListener (Mouse.addListener method)
removeListener (Mouse.removeListener method)
public static removeListener(listener:Object) : Boolean
Removes an object that was previously registered with addListener().
Note: This method is supported in Flash Lite only if
System.capabilities.hasMouse is
true or System.capabilities.hasStylus is true.
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
listener:Object - An object.
Returns
Boolean - If the listener object is successfully removed, the method returns true; if the
listener object is not successfully removed (for example, if it was not on the Mouse object's
listener list), the method returns
false.