Testing pivotPoint argument of prependRotation() method
♥0 |
Line 34 |
Modified 2010-01-13 18:44:55 |
MIT License
archived:2017-03-09 19:59:42
ActionScript3 source code
/**
* Copyright Fumio ( http://wonderfl.net/user/Fumio )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/tOTV
*/
package {
import flash.display.Sprite;
import flash.display.Graphics;
import flash.geom.Matrix3D;
import flash.geom.Vector3D;
import flash.events.Event;
public class prependRotationPivotPointTest extends Sprite {
private var mySprite:Sprite;
private var nX:Number = stage.stageWidth / 2;
private var nY:Number = stage.stageHeight / 2;
private var nRotationY:Number = 5;
private var myMatrix3D:Matrix3D = new Matrix3D();
private var pivotVector3D:Vector3D = new Vector3D(nX,nY,0);
public function prependRotationPivotPointTest() {
mySprite = createRectangle();
mySprite.transform.matrix3D = myMatrix3D;
myMatrix3D.appendTranslation(nX, nY, 0);
addChild(mySprite);
addEventListener(Event.ENTER_FRAME, xRotate);
}
private function createRectangle():Sprite {
var _sprite:Sprite = new Sprite();
var myGraphics:Graphics = _sprite.graphics;
myGraphics.beginFill(0x0000FF);
myGraphics.drawRect(-50, -50, 100, 100);
myGraphics.endFill();
return _sprite;
}
private function xRotate(eventObject:Event):void {
myMatrix3D.appendTranslation(-nX, -nY, 0);
// myMatrix3D.appendRotation(nRotationY, Vector3D.Y_AXIS);
// myMatrix3D.appendTranslation(nX, nY, 0);
// The two statements above are equivalent to the next statement.
myMatrix3D.appendRotation(nRotationY, Vector3D.Y_AXIS, pivotVector3D);
}
}
}