拡大縮小
/**
* Copyright Wataru.Miyazaki ( http://wonderfl.net/user/Wataru.Miyazaki )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/3hgU
*/
// forked from Wataru.Miyazaki's 回転
package {
import flash.display.*;
import flash.text.*;
import flash.events.*;
import flash.utils.*;
import flash.filters.*;
import com.actionscriptbible.Example;
public class ShapeRot extends Example {
private var base:Sprite;
private var rrect:Shape;
private var mouseMove:Boolean;
public function ShapeRot() {
base = new Sprite();
base.x = 120;
base.y = 120;
addChild(base);
// baseに対して、四角をadd
rrect = makeRect(100, 100, 0xff0000);
rrect.x = -50;
rrect.y = -50;
base.addChild(rrect);
}
//角丸矩形の生成
private function makeRect(w:uint,h:uint,color:uint):Shape {
var rrect:Shape=new Shape();
rrect.graphics.lineStyle(3,0x000000); //線幅・線色
rrect.graphics.beginFill(color); //塗り潰し色
rrect.graphics.drawRect(0,0,w,h);//XY座標,幅,高さ,角丸幅
rrect.graphics.endFill(); //塗り潰し終了
return rrect;
}
//=============================================================================
// 回転 baseMarkerのマウスイベント
private function onMouseDownMarker(e:MouseEvent):void{
trace("onMouseDownButton");
mouseMove = true;
e.currentTarget.startDrag();
}
private function onMouseUpMarker(e:MouseEvent):void{
trace("onMouseUpButton");
mouseMove = false;
e.currentTarget.stopDrag();
}
private function onMouseMove(e:MouseEvent):void{
//trace("onMouseMove",e.stageX,e.currentTarget.x,fld.x);
if(mouseMove){
trace("mousemove",e.stageX,e.stageY);
trace("center",rrect.x,rrect.y,rrect.width,rrect.height);
//var radian:Number = Math.atan2(e.stageY - base.y, e.stageX - base.x);
//var degree:Number = radian * 180 / Math.PI;
//base.rotation = degree;
base.scaleX = (e.stageX - base.x)*2/100;
base.scaleY = (e.stageY - base.y)*2/100;
rrect.graphics.lineStyle(3,0x000000); //線幅・線色
//base.x = e.stageX - base.width/2;
}
}
}
}