MACROMEDIA FLEX-FLEX ACTIONSCRIPT LANGUAGE Reference page 364

Actionscript language reference
Table of Contents

Advertisement

Description
Listener; notified when the mouse is pressed. To use the
listener object. You can then define a function for
register the listener with the Mouse object, as shown in the following code:
var someListener:Object = new Object();
someListener.onMouseDown = 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 Drawing API to draw a rectangle whenever the user clicks, drags
and releases the mouse at runtime.
this.createEmptyMovieClip("canvas_mc", this.getNextHighestDepth());
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function() {
this.isDrawing = true;
this.orig_x = _xmouse;
this.orig_y = _ymouse;
this.target_mc = canvas_mc.createEmptyMovieClip("",
canvas_mc.getNextHighestDepth());
};
mouseListener.onMouseMove = function() {
if (this.isDrawing) {
this.target_mc.clear();
this.target_mc.lineStyle(1, 0xFF0000, 100);
this.target_mc.moveTo(this.orig_x, this.orig_y);
this.target_mc.lineTo(_xmouse, this.orig_y);
this.target_mc.lineTo(_xmouse, _ymouse);
this.target_mc.lineTo(this.orig_x, _ymouse);
this.target_mc.lineTo(this.orig_x, this.orig_y);
}
updateAfterEvent();
};
mouseListener.onMouseUp = function() {
this.isDrawing = false;
};
Mouse.addListener(mouseListener);
See also
Mouse.addListener()
364
Chapter 6: ActionScript Core Classes
listener, you must create a
onMouseDown
and use
onMouseDown
to
addListener()

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flex

Table of Contents