I have 1 arrow with 2 arrows inside it. Can anyone tell me how to have all 3 arrows point at the cursor?
I think I need to into account the angle of the parent or something but I don’t know how to do that
see the attached fla (cs5)
import flash.events.*;
import flash.display.*;
stage.addEventListener(Event.ENTER_FRAME, loop);
function loop(e:Event):void
{
PointAtCursor(a1);
PointAtCursor2(a1.a2);
PointAtCursor2(a1.a3);
}
function PointAtCursor(obj:MovieClip):void {
var a:Number = stage.mouseY - obj.y;
var b:Number = stage.mouseX - obj.x;
var angle:Number = Math.atan2(a, b);
angle = angle * (180 / Math.PI);
obj.rotation = angle;
}
//for nested objects
function PointAtCursor2(obj:MovieClip):void {
var a:Number = stage.mouseY - obj.localToGlobal(new Point(obj.x, obj.y)).y;
var b:Number = stage.mouseX - obj.localToGlobal(new Point(obj.x, obj.y)).x;
var angle:Number = Math.atan2(a, b);
angle = angle * (180 / Math.PI);
obj.rotation = angle;
}
Thanks!!