Cursor image to the center on mouseout
Posted
by Milla
on Stack Overflow
See other posts from Stack Overflow
or by Milla
Published on 2009-11-17T07:53:33Z
Indexed on
2010/03/24
3:03 UTC
Read the original article
Hit count: 364
flash
|actionscript-3
Hi all!
I'm a real noobie with flash and I was wondering if somebody could help me with this one.
I have this actionsript 3 code, where the cursor image "ball_mc" follows the mouse's position with a slight delay:
stage.addEventListener(Event.ENTER_FRAME,followBall);
function followBall(event:Event):void {
var dx:int = ball_mc.x - mouseX;
var dy:int = ball_mc.y - mouseY;
ball_mc.x -= dx / 5;
ball_mc.y -= dy /5;
}
1) How can I get the cursor image automatically return to the center of the stage on mouseout? As of now, it stays at the position where the mouse leaves the stage.
2) How can I reverse the movement of the mouse? So that when I, for example, move mouse to the right, the cursor image would move to the left? And when moving the mouse up, the image would go down.
The stage is 800 x 250 pixels, in case that makes any difference.
© Stack Overflow or respective owner