views:

52

answers:

2

I am working on a Flash Project in which i have to rotate a text field.I am Rotating the text field using this function---

**function rotateAroundCenter(ob:*, angleDegrees)
{

    var m:Matrix = ob.transform.matrix;
    m.tx -=  point.x;
    m.ty -=  point.y;
    m.rotate(angleDegrees*(Math.PI/180));
    m.tx +=  point.x;
    m.ty +=  point.y;
    ob.transform.matrix = m;
}**

var point:Point = new Point(mc.x+ mc.width / 2,mc.y+ mc.height / 2);


i am calculating the center point of mc containing the textfield using the above method.

I Have also povided the dragging feature so that one can drag the text field. The problem is when i rotate the text field say 45 degrees and then i drag it to other position now if i rotate the text field again it is not rotating about its center or origin, it rotates about some other point that is calculated by the same method ---mc.x+ mc.width / 2,mc.y+ mc.height / 2---

How do i calculate the perfect origin of a text field at any angle of rotation.

A: 

Use the search, man... here is example with Rotate effect. You can adapt the math from there.

alxx
A: 

You're rotating mc or textfield? If you're rotating textfield, so you have to get width from it. Rotating textfield and dragging mc is best for performance.

rotateAroundCenter(textField, 45);
var point:Point = new Point(textField.width / 2, textField.height / 2);
Dmitri Semenov