1. How to use the Matrix class to change the registration point:
Do album function when the most annoying is the registration point in (0,0) position, in order to be able to easily rotate, zoom operation, need to move the registration point to the center, reference snow Cat method, made a simplification:
Code VARŌBJ = this. Myimagebitmap; The picture or movie clip you want to change
var matrix:matrix = Obj.transform.matrix;
MATRIX.TX = 0;
Matrix.ty = 0;
var halfw:number = OBJ.WIDTH/2;
var halfh:number = OBJ.HEIGHT/2;
Matrix.translate (-1 * HALFW,-1 * halfh);
This way in the rotation, scaling operation can see the registration Point Center effect, in fact, is to use the Transale function of the matrix properties of TX, Ty value to the upper left corner of the direction of moving half width and height;
2. When you save the image, you will not see the picture once you have done a rotation operation.
Although the matrix translation method can change the registration point, and in fact AS3 0 does not really change the registration point (other online methods are also), the registration point is still in the (0,0) point, but this to the rotation, scaling will have a registration point in the center of the effect. However, once the use of the Rorate function for rotation, this corner of the registration point will be followed by mobile, for example, the picture clockwise 90 degrees, then, the original in the upper left corner of the registration point, but will move to the upper right corner.
While saving the image, AS3.0 is to align the image registration point to the upper-left corner of your bitmapdata object, it is not difficult to imagine what the image will look like after the save. If the image is not rotated, the registration point is in (0,0), which should be perfect for the image; Once you rotate in either direction, you will not see anything, because the content of the image has gone beyond the bounds of the bitmapdata.
The solution is to do the correct translation of the incoming matrix when the BitmapData draw (Myimagebitmap.bitmapdata, New Matrix ()) method is written to the image when it is saved.
For example, assuming that you are only doing a 90-degree rotation each time (as with the rotation of XP's own picture browser), do a calculation and a peaceful move before performing the Save function, and here is a simple algorithm:
Code var tx:number = mymatrix.tx, ty:number = Mymatrix.ty;
var tx1:number = 0, ty1:number = 0;
if (TX < 0 && Ty < 0)
{
TX1 =-1 * TX;
ty1 =-1 * ty;
}
else if (tx > 0 && ty < 0)
{
TX1 = TX;
ty1 =-1 * ty;
}
else if (tx > 0 && ty > 0)
{
TX1 = TX;
ty1 = Ty;
}
else if (TX < 0 && ty > 0)
{
TX1 =-1 * TX;
ty1 = Ty;
}
Mymatrix.translate (TX1, ty1)
Then call BitmapData's Draw method write, and in the execution save function, you should be able to see the correct image.