onClipEvent(mouseDown) {
trace("mouse pressed");
}
onClipEvent(mouseUp) {
trace("mouse released");
}
onClipEvent(mouseMove) {
trace("mouse is moving");Here it goes:
trace("mouse pressed");
}
onClipEvent(mouseUp) {
trace("mouse released");
}
onClipEvent(mouseMove) {
trace("mouse is moving");Here it goes:
- Hiding the Mouse
There may be times when you don't want the mouse cursor visible on your screen. To hide the mouse, simply add the following line of code to a movie, frame, or button:
If possible, do try to not hide the mouse cursor. While you may have a cooler mouse pointer created in Flash for your animation, it is bad design to hide the mouse cursor - almost as bad as an unwanted pop-up.
- Showing the Mouse
By default, the cursor will be visible over your animation. If you want to display the mouse cursor that you may have hidden from view (see above step), use the following code:
- Getting X and Y Mouse Values
The x and y positions of the mouse are basically numbers. The numbers can be accessed and manipulated by using the mouse pointer's position properties: _xmouse and _ymouse.
In the above code, xval gets the x position of the mouse while yval gets the y position of the mouse. It is best to place this code in the onClipEvent(enterFrame) or onClipEvent(mouseMove) handler to ensure the data gets updated continuously with the latest mouse co-ordinates.
- mouseDown, mouseUp, mouseMove
In most animations, the event handlers you will use are onLoad, onEnterFrame, release, etc. But, did you know you can execute actions only when the mouse is pressed, when the mouse is released, and when the mouse is moved?
For an example of this, copy and paste the following code into the actions for a movie clip and press Ctrl + Enter:
onClipEvent(mouseDown) {
trace("mouse pressed");
}
onClipEvent(mouseUp) {
trace("mouse released");
}
onClipEvent(mouseMove) {
trace("mouse is moving");
trace("mouse pressed");
}
onClipEvent(mouseUp) {
trace("mouse released");
}
onClipEvent(mouseMove) {
trace("mouse is moving");