We want to scale, rotate and drag functionality in flash as3.
I do have some code. It’s rotation functionality is working good. But After we rotate image, zooming functionality does not work.
we rotate, and zoom image by one reference point.
Here is code:
function scaleRotateFromPoint(sx:Number, sy:Number, ptCenter:Point, angle:Number):void{
var mat:Matrix = imgMat.clone();
mat.tx -= ptCenter.x;
mat.ty -= ptCenter.y;
mat.rotate (angle*(Math.PI/180));
mat.scale(sx,sx);
mat.tx += ptCenter.x;
mat.ty += ptCenter.y;
loaderFirst.transform.matrix = mat;
}
we need to pass one point, zoom value and rotation angle.
Thanks in advance.
I’ve just had a play with your function in Flash, and it seems to work perfectly for me.
I changed the code so that it took the transform object as a parameter, and set the modified matrix after modifying it to make absolutely sure it was being used correctly.
The apparent problem might be because you’re specifying the center point in the
DisplayObject‘s local co-ordinates. The center point is specified in the parent co-ordinate space.If you need to specify the co-ords in local space, one straightforward way to convert between co-ordinate spaces by using the
DisplayObject.localToGlobal()andglobalToLocal()functions. (Alternatively, you caninvert()the local matrix, andtransformPoint()to get a point in theparent‘s space.)