# Cursor follow script

**URL:** <https://forum.kirupa.com/t/cursor-follow-script/167711>\
**Category:** Uncategorized\
**Created:** [October 31, 2005, 8:32am UTC](https://forum.kirupa.com/t/cursor-follow-script/167711 "2005-10-31T08:32:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![manga](https://avatars.discourse-cdn.com/v4/letter/m/6bbea6/32.png) [@manga](https://forum.kirupa.com/u/manga)\
**Post date:** [October 31, 2005, 8:32am UTC](https://forum.kirupa.com/t/cursor-follow-script/167711/1 "2005-10-31T08:32:23Z")

</div>

Hey all,

i use this script to make a custom cursor and rotate it to the direction the \_root.\_x,ymouse goes…  
but i think it can be more improved can somebody have a look?

onClipEvent (enterFrame) {  
Mouse.hide()  
mouse\_x = int(\_root.mouse.\_x-this.\_x);  
mouse\_y = int(\_root.mouse.\_y-this.\_y);  
if (mouse\_x\>0 && mouse\_y\>0) {  
quad = Number(4);  
}  
if (mouse\_x\<0 && mouse\_y\>0) {  
quad = Number(1);  
}  
if (mouse\_x\<0 && mouse\_y\<0) {  
quad = Number(2);  
}  
if (mouse\_x\>0 && mouse\_y\<0) {  
quad = Number(3);  
}  
abs\_x = Math.abs(mouse\_x);  
abs\_y = Math.abs(mouse\_y);  
[//tg=Math.atan](https://tg=Math.atan)(abs\_y,abs\_x)  
tg =abs\_y/abs\_x;  
\_root.maths = Math.atan(tg)\*Number(180)/Math.PI;  
if (quad == 1) { angle = number(90) - number(\_root.maths) }  
if (quad == 2) { angle = number(90) + number(\_root.maths) }  
if (quad == 3) { angle = number(270) - number(\_root.maths) }  
if (quad == 4) { angle = number(270) + number(\_root.maths) }

setProperty (\_this, \_rotation, angle);  
this.\_x+=(\_root.\_xmouse-this.\_x)/2;  
this.\_y+=(\_root.\_ymouse-this.\_y)/2;  
}

Thanks,  
M
