Hello everyone!
Hope life is good
What I am trying to do is get an arrow to spin and always point at the curser.
What I have done is created to movie clips, one that is empty but has this code (this clip has the instance name of clip)
onClipEvent(enterFrame){
x = (_root._xmouse - _root.comp._x);
y = (_root._ymouse - _root.comp._y);
hyp = Math.sqrt(Math.pow(x,2) + Math.pow(y,2));
cos = x / hyp;
rad = Math.acos(cos);
deg = Math.floor(180/(Math.PI / rad));
if(y <0){
deg = -deg;
}else if((Math.floor(y) == 0) && (x <0)){
deg = 180;
}
}
onClipEvent(mouseDown){
trace("x = " + x);
trace("y = " + y);
trace("hyp = " + hyp);
trace("cos = " + cos);
trace("rad = " + rad);
trace("deg = " + deg);
}
On the second movie clip I have an arrow and the following code (this clip has an instance name of comp)
clip.deg.
onClipEvent(enterFrame){
this._rotation = _root.clip.deg;
}
I can only get it to follow the cursor for 90 degs not the full 360.
Any help would be well helpful
Thanks,
Matt