I need to allow the user to rotate a polygon in a graphics layer. I can do this via text input into a textbox but I would like to allow them to do this via the mouse if they wish and for the angle of rotation to be displayed in the input box as they change it with the mouse. This is the code I have for the rotation bit at the moment!//If a rotation angle is specified, call the rotation function
var rotationNumber:Number = 0;
rotationNumber = parseFloat(txt_Rotation.text);
if(rotationNumber != 0)
{ //Go through array of points and calculate new point location.
var x:Number = 0;
var y:Number = 0;
var rotationAngle:Number = parseFloat("-" + txt_Rotation.text); //made negative so that behaves as compass bearing degrees rather than radian degree logic
for(i = 0; i < ringArr.length; i++)
{ //Logic as follows: New x = originX (around which polygon must rotate) + ((point to rotate X - origin X) * cos(angle value) - (point to rotate Y - origin Y) * sin (angle value))
x = ringArr[0].x + (int) ((ringArr.x - ringArr[0].x) * Math.cos(Math.PI/180 * rotationAngle) - (ringArr.y - ringArr[0].y) * Math.sin(Math.PI/180 * rotationAngle));
y = ringArr[0].y + (int) ((ringArr.x - ringArr[0].x) * Math.sin(Math.PI/180 * rotationAngle) + (ringArr.y - ringArr[0].y) * Math.cos(Math.PI/180 * rotationAngle));
//Original code the above was derived from:
//int X = origin.x + (int) ((point.x - origin.x) * cos(angle) - (point.y - origin.y) * sin(angle));
//int Y = origin.y + (int) ((point.x - origin.x) * sin(angle) + (point.y - origin.y) * cos(angle));
//point = CPoint(X, Y);
ringArr = new MapPoint(x,y);
}
}
this is part of the routine that displays a polygon which originates at an x/y location input by the user. The purpose is for angles of fire of a weapon and the polygon represents the weapons danger area which will be plotted on a map to safely plan firing exercises.Hope someone can helpcheersgraham