# Can someone explain it to me...?

**URL:** <https://forum.kirupa.com/t/can-someone-explain-it-to-me/77417>\
**Category:** Uncategorized\
**Created:** [January 27, 2005, 2:59am UTC](https://forum.kirupa.com/t/can-someone-explain-it-to-me/77417 "2005-01-27T02:59:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eiefai](https://avatars.discourse-cdn.com/v4/letter/e/e56c9b/32.png) [@eiefai](https://forum.kirupa.com/u/eiefai)\
**Post date:** [January 27, 2005, 2:59am UTC](https://forum.kirupa.com/t/can-someone-explain-it-to-me/77417/1 "2005-01-27T02:59:20Z")

</div>

i got this code to make my character move when the mouse is clicked, but im not sure how it works.

> 

onClipEvent (load) {  
clickSpot\_x = \_x;  
clickSpot\_y = \_y;  
speed = 4;  
}  
onClipEvent (mouseDown) {  
clickSpot\_x = \_root.\_xmouse;  
clickSpot\_y = \_root.\_ymouse;  
}  
onClipEvent (enterFrame) {  
gotoSpotX = clickSpot\_x;  
gotoSpotY = clickSpot\_y;  
delta\_x = \_x-gotoSpotX;  
delta\_y = \_y-gotoSpotY;  
targetRotation = -Math.atan2(delta\_x, delta\_y)/(Math.PI/180);  
\_rotation = targetRotation;  
**if (Math.sqrt((delta\_x_delta\_x)+(delta\_y_delta\_y))\>speed) {  
\_y -= speed_Math.cos(\_rotation_(Math.PI/180));  
\_x += speed_Math.sin(\_rotation_(Math.PI/180));  
}**  
}

if someone can tell me why it moves i’ll be very thankfull
