I use transform.matrix.
I create dynamically several objects. Than place them on scene (X Y) and apply transformatiom matrix to them, to rotate and scale object via it`s central point.
Code:
for (var i:Number=1; i<6; i++) {
OOK_Matrix[i] = OOK_Movie[i].transform.matrix;
var pGlobal:Point = OOK_Movie[i].localToGlobal(new Point(OOK_Movie[i].width/2, OOK_Movie[i].height/2));
OOK_Points[i] = OOK_Movie[i].parent.globalToLocal(pGlobal);
//trace(Angle);
}
All works grate. But I have follow problem:
I need to change object position on screen. I set new X and Y. Objects moved to new place. All ok. But next operations with rotate and scale works some strange, not around it`s central point.
For example rotation I do by next code:
Code:
rotateMatrixMethodsOnly(OOK_Movie[i],Angle,OOK_Matrix[i], OOK_Points[i]);
function rotateMatrixMethodsOnly( obj:DisplayObject, angle:Number, mmtr:Matrix, pRotate_:Point ):void
{
var rad:Number = angle * (Math.PI / 180);
mmtr.translate( -pRotate_.tx, -pRotate_.ty );
mmtr.rotate( rad );
mmtr.translate( pRotate_.tx, pRotate_.ty );
obj.transform.matrix = mmtr;
}