Mouse Location Tracking with Flash ActionScript 3
Many Flash Movies require to track the location of mouse pointer as well as the status of the mouse pointer. This Flash ActionScript tutorial series show how to do some mouse control.Flash Tutorial Content:
In this Flash ActionScript tutorial, we will write a very simple function so that the current location of Mouse Pointer can be tracked easily with ActionScript.
The complete Flash Movie is shown as above, you may try how it works before you start this tutorial.
Flash ActionScript Codes:
////////////////////////////////////////////////////////
///// Check the location of Mouse Pointer when click /////
////////////////////////////////////////////////////////
function mouseClickLoc(evt:MouseEvent):void {
}
stage.addEventListener(MouseEvent.CLICK, mouseClickLoc);
/////////////////////////////////////////////////////////////////////////////
///// Keep tracking the location of moving Mouse Pointer /////
/////////////////////////////////////////////////////////////////////////////
function mouseMoveLoc(motion:MouseEvent):void {
}
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveLoc);
Download Flash Source File:
Remarks:
Sometimes it also requires to know when the Mouse Pointer is over an object and when it leaves the object. The next Flash ActionScript tutorial will show how to do it.