In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

ベジェ曲線の実験途中。

Get Adobe Flash player
by moringo 23 Feb 2009
package {
    import flash.display.*;
	import flash.events.*;
	import caurina.transitions.Tweener;
    public class FlashTest extends Sprite {
		
		private var colorArray:Array = [0x2A95BF,0x6CBAD9,0x015CA5,0x187DC1,0xD2D6D9,0xF2B90F,0xDFFF24,0x85DB18,0xFF358B];
		private var sp:Sprite;
		private var bz:BezeirLine;
		private var p:Number = 0; //ベジェ曲線のパラメーラ
		private var sPoint:Array = [0,0] //描画開始点
		private var ePoint:Array = [0,0] //描画終了点
		private var h1:Array= [0,0] //方向点1
		private var h2:Array= [0,0] //方向点2
		
        public function FlashTest() {
            bz = new BezeirLine();
            drawStart();
        }
				
		private function drawStart():void{
			
			//ベジェの各点を作成
			h1 = [Math.random()*stage.stageWidth,Math.random()*stage.stageHeight]
			h2 = [Math.random()*stage.stageWidth,Math.random()*stage.stageHeight]
			sPoint =[0,Math.random()*stage.stageHeight]
			ePoint =[stage.stageWidth,Math.random()*stage.stageHeight]
			
			//曲線描画のスプライトを用意する。
			sp = new Sprite();
			sp.graphics.clear();
			sp.graphics.lineStyle(1,colorArray[Math.floor(Math.random()*colorArray.length)]);
			sp.graphics.moveTo(sPoint[0],sPoint[1]);
			addChild(sp);
			
			//ベジェのパラメータをリセットして描画開始。
			p = 0;
			addEventListener(Event.ENTER_FRAME,loop)
		}
		
		private function loop(e:Event):void{
			p += 0.005;
			if(p<1){				
				var bezierP:Array = bz.getBezeirPoints(sPoint,ePoint,h1,h2,p);
				sp.graphics.lineTo(bezierP[0],bezierP[1]);
				if(Math.random() < 0.2){
					var sprite:Sprite = new Sprite();
					addChild(sprite);
					sprite.graphics.beginFill(colorArray[Math.floor(Math.random()*colorArray.length)]);
					sprite.graphics.drawCircle(0,0,10*Math.random());
					sprite.graphics.endFill();
					sprite.x = bezierP[0]
					sprite.y = bezierP[1]
				}
			}else{
				removeEventListener(Event.ENTER_FRAME,loop);
				drawStart();
			}
		}

    }
	
}

import flash.display.*;
import flash.events.*;
class BezeirLine extends Sprite {
	
	public var t:Number = 0;
	
	function BezeirLine(){
	}
	
        //ベジェ曲線上の座標を返す
	public function getBezeirPoints(point1:Array,point2:Array,c1:Array,c2:Array,p:Number):Array{
		var points:Array =[];
		var xP:Number = Math.pow((1-p),3)*point1[0] + 3*Math.pow((1-p),2)*p*c1[0] + 3*(1-p)*p*p*c2[0] + p*p*p*point2[0];
		var yP:Number = Math.pow((1-p),3)*point1[1] + 3*Math.pow((1-p),2)*p*c1[1] + 3*(1-p)*p*p*c2[1] + p*p*p*point2[1];
		points = [xP,yP];
		return points;
	}
	
}