I'm trying to find the best way to rotate a container (or anything for that matter) using the matrix3D features in flash 10 for flex.
I have managed to get a container to rotate around a point that is not its registration point but I’ve only managed this by turning off the clipping on a container then placing the contents somewhere other than (0,0,0). This does work, but it’s not very intuitive and sucks when trying to place several items or even if you need to move the rotation point.
Using the matrix3D class seems to be the way to go, but I'm not sure exactly how.
Cheers
Additional info - If my container is at (0,0,0) on the stage and I wish to rotate around the middle X coord of container then I translate by container.width/2 for the X then rotate and translate back again. This works fine. BUT if my container is say at (10, 0, 0) then if I translate the same as above and add the extra 10 then it doesn't work.
Soloution (which is complete rubbish - please explain if you can)
As has been suggested you need to translate, rotate, then -traslate. I knew this but it never worked.
BUT see the soloution below, I don't get it. (panel is the object I'm rotating, I call function both() )
private function rotateOnly() : void {
panel.transform.matrix3D.appendRotation(36, Vector3D.Y_AXIS);
}
private var valueToMove : Number = 300;
private var translateUpOrDown : Boolean = false;
private function translateOnly() : void {
if(translateUpOrDown){
panel.transform.matrix3D.appendTranslation(valueToMove, 0, 0);
translateUpOrDown = false;
} else {
panel.transform.matrix3D.appendTranslation(-valueToMove, -0,0);
translateUpOrDown = true;
}
}
//I do not run both chunks of code here at once, this is only to show what I've tried
private function both() : void {
//IF I call this function and call this chunk then the rotation works
translateOnly();
rotateOnly();
translateOnly();
//If I call this chunk which does the exact same as the above it does NOT work!!
panel.transform.matrix3D.appendTranslation(valueToMove, 0,0);
panel.transform.matrix3D.appendRotation(36, Vector3D.Y_AXIS);
panel.transform.matrix3D.appendTranslation(-valueToMove, 0,0);
}