forked from: flash on 2010-2-7

by sheep forked from flash on 2010-2-7 (diff: 49)
♥0 | Line 35 | Modified 2010-02-07 13:49:51 | MIT License
play

ActionScript3 source code

/**
 * Copyright sheep ( http://wonderfl.net/user/sheep )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/azHr
 */

// forked from sheep's flash on 2010-2-7
package {
    import flash.display.MovieClip
    public class Index extends MovieClip {
        public function Index() {
        		var myCircle1:DrawCircle = new DrawCircle();
        		var myCircle2:DrawCircle = new DrawCircle();
        		var myCircle3:DrawCircle = new DrawCircle();
        		myCircle1.x = 50;
        		myCircle2.y = 200;
        		myCircle3.y = 100
        		addChild(myCircle1);
        		addChild(myCircle2);
        		addChild(myCircle3);
        		removeChild(myCircle1);//
        }
    }
}
	//クラスにすることでひとつひとつをインスタンスとして扱うことが出来る
    import flash.display.MovieClip;
    class DrawCircle extends MovieClip {
        public function DrawCircle() {
            // write as3 code here..
            var centerX:Number = 100;
            var centerY:Number = 200;
            var r:Number = 50;
       
            graphics.lineStyle(2, 0xFF0006);
            graphics.moveTo(centerX+r, centerY);
            /*y = Math.tan(-)*r */
            /* grahics.curveTo(コントロールポイントのx,y, 終点x,y) */
            //右下
            graphics.curveTo(r+centerX, Math.tan(Math.PI/8)*r+centerY, Math.sin(Math.PI/4)*r+centerX, Math.sin(Math.PI/4)*r+centerY);
            graphics.curveTo(Math.tan(Math.PI/8)*r+centerX, r+centerY, centerX, r+centerY);
            //左下
            graphics.curveTo(-Math.tan(Math.PI/8)*r+centerX, r+centerY, -Math.sin(Math.PI/4)*r+centerX, Math.sin(Math.PI/4)*r+centerY);
            graphics.curveTo(-r+centerX, Math.tan(Math.PI/8)*r+centerY, -r+centerX, centerY);
            //左上
            graphics.curveTo(-r+centerX, -Math.tan(Math.PI/8)*r+centerY, -Math.sin(Math.PI/4)*r+centerX, -Math.sin(Math.PI/4)*r+centerY);
            graphics.curveTo(-Math.tan(Math.PI/8)*r+centerX, -r+centerY, centerX, -r+centerY);
            //右上
            graphics.curveTo(Math.tan(Math.PI/8)*r+centerX, -r+centerY, Math.sin(Math.PI/4)*r+centerX, -Math.sin(Math.PI/4)*r+centerY);
            graphics.curveTo(r+centerX, -Math.tan(Math.PI/8)*r+centerY, r+centerX, centerY);
             
        }
    }

Forked