I designed this script to take two points (ie x and y), convert those to an angle rotate it so many degrees and then change the points accordingly. I put together a little test and it does not seem to function as planned. It rotates somewhat, but then begins to click back and forth. Here is my code:
point = new Array(100, 50);
offset = new Array(Stage.width/2, Stage.height/2)
_root.lineStyle(0, 0x000000, 100);
_root.moveTo(offset[0], offset[1]);
_root.lineTo(point[0]+offset[0], point[1]+offset[1]);
_root.onMouseDown = function() {
am = -10
var rad = Math.sqrt((point[0]*point[0])+(point[1]*point[1]));
var currang = (Math.asin(point[0]/rad))*(180/Math.PI);
currang = (currang > 360) ? currang-360 : currang;
currang = (currang < 0) ? currang+360 : currang;
var newang = currang+am;
newang = (newang > 360) ? newang-360 : newang;
newang = (newang < 0) ? newang+360 : newang;
point[0] = Math.sin(newang*(Math.PI/180))*rad;
point[1] = Math.cos(newang*(Math.PI/180))*rad;
trace(currang)
_root.moveTo(offset[0], offset[1]);
_root.lineTo(point[0]+offset[0], point[1]+offset[1]);
};
Does anyone know why?
PS zipped .swf/.fla attached