Add mouse move listener
package {
import flash.display.Sprite;
import flash.events.*;
import flash.geom.Point;
public class Main extends Sprite {
public function Main( ) {
var circle:Sprite = new Sprite( );
circle.x = 10;
circle.y = 10;
circle.graphics.beginFill( 0xFF0000 );
circle.graphics.drawCircle( 0, 0, 5 );
circle.graphics.endFill( );
circle.addEventListener( MouseEvent.MOUSE_MOVE, handleMouseMove );
addChild( circle );
}
private function handleMouseMove( event:MouseEvent ):void {
trace( "local x: " + event.localX );
trace( "local y: " + event.localY );
var localPoint:Point = new Point( event.localX, event.localY );
var globalPoint:Point = event.target.localToGlobal( localPoint );
trace( "global x: " + globalPoint.x );
trace( "global y: " + globalPoint.y );
}
}
}
Related examples in the same category