Jacob
Jacob

Reputation: 27

AS3 Movieclip center rotation and top left X,Y points

I am creating a flash image cropper. I can resize and move a movieclip containing my image. This movieclip can also be rotated.

The problem I am having is that in order to crop the image properly I need the original X,Y coordinates at the point where the image is at 0 degrees. This is the moveable movieclip I am talking about.

Is there anyway I can take the rotation degree and the current top left X,Y and get the original point at 0 degrees?

Thanks for the assistance

Upvotes: 0

Views: 1719

Answers (2)

loxxy
loxxy

Reputation: 13151

Why can't you just:

  • Rotate it to 0 degree.

  • Get the new x, y.

  • Rotate it back by the angle.


BTW, it is always best to rotate by the center. So you have to apply something like

  • Translate back by half the width & half the height.

  • Rotate it by the angle.

  • Translate back...

Upvotes: 0

Chris
Chris

Reputation: 1431

Well, you could just let DisplayObject do your job for you:

var tempRotation:Number = displayObject.rotation;
displayObject.rotation = 0;
var referencePoint:Point = new Point(displayObject.x, displayObject.y);
displayObject.rotation = tempRotation;

Upvotes: 1

Related Questions