かなり原始的な例ですが、回転前の基準点と回転後の基準点を測り、
ずれた分だけ移動させています。
import flash.display.MovieClip;
mc_box.addEventListener(Event.ENTER_FRAME, rotate);
//回転の中心
var tmp_pos : Point = new Point( ( mc_box.width/2 ) / (mc_box.scaleX), (mc_box.height / 2) / (mc_box.scaleY));
function rotate(event:Event):void{
//回転前の座標
var global_pos : Point = mc_box.localToGlobal(tmp_pos);
mc_box.rotation++;
//回転後の座標
var after_pos : Point = mc_box.localToGlobal(tmp_pos);
mc_box.x = mc_box.x - (after_pos.x - global_pos.x);
mc_box.y = mc_box.y - (after_pos.y - global_pos.y);
}
数学的な厳密さを求めなければこれでも十分機能すると思いますが、
rotateAroundInternalPoint() を使えばもっと簡単にかけます。
rotateAroundInternalPoint(Matrix, X座標, Y座標, 変化角度)
参考
http://fumiononaka.com/TechNotes/Flash/FN0708001.html
import flash.display.MovieClip;
import flash.display.DisplayObject;
import flash.geom.Matrix;
import fl.motion.MatrixTransformer;
mc_box.addEventListener(Event.ENTER_FRAME, rotate);
//回転の中心
var tmp_pos : Point = new Point( ( mc_box.width/2 ) / (mc_box.scaleX), (mc_box.height / 2) / (mc_box.scaleY));
function rotate(event:Event):void{
var myMatrix:Matrix = mc_box.transform.matrix;
MatrixTransformer.rotateAroundInternalPoint(myMatrix, tmp_pos.x, tmp_pos.y, 1);
mc_box.transform.matrix = myMatrix;
}
こちらは角度を指定するのではなく、何度ずつ回転するかを指定するタイプです。
Similar Posts:
- [AS3.0]オブジェクトを複製してドラッグ操作する
- Flash ファイルアップロード AS3.0
- [AS3.0]変形した MovieClip のローカルマウス座標
- [PHP]中心から角度を指定して線を引く(座標の回転)
- [JS]画像ファイルアップロード前にプレビューを表示する
- [PHP]レーダーチャート(クモの巣グラフ)をGDで描画する
- [HTML5+JS+Canvas, PHP]アナログ時計の作り方
- [CSS, jQuery]クリックされたボタンの色を変更したり文字を書き換えたりする