User Guide

Mouse.onMouseUp 483
Mouse.onMouseUp
Availability
Flash Player 6.
Usage
someListener.onMouseUp
Parameters
None.
Returns
Nothing.
Description
Listener; notified when the mouse is released. To use the onMouseUp listener, you must create a
listener object. You can then define a function for
onMouseUp and use addListener() to register
the listener with the Mouse object, as shown in the following code:
var someListener:Object = new Object();
someListener.onMouseUp = function () { ... };
Mouse.addListener(someListener);
Listeners enable different pieces of code to cooperate because multiple listeners can receive
notification about a single event.
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 when they drag the mouse pointer. The user stops drawing
the line when they release 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
Mouse.addListener()