EasyManua.ls Logo

MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE - Onmousedown (Mouse.onmousedown Event Listener)

MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
1378 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Mouse 809
updateAfterEvent();
};
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
show (Mouse.show method), _xmouse (MovieClip._xmouse property), _ymouse
(MovieClip._ymouse property)
onMouseDown (Mouse.onMouseDown event
listener)
onMouseDown = function() {}
Notified when the mouse is pressed. To use the onMouseDown listener, you must create a
listener object. You can then define a function for
onMouseDown and use addListener() to
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.
A Flash application can only monitor mouse events that occur within its focus. A Flash
application cannot detect mouse events in another application.
Availability: ActionScript 1.0; Flash Player 6
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) {

Table of Contents

Related product manuals