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

2次ベジェ曲線の連続に変更中。

package {
    import flash.display.*;
	import flash.events.*;
	import caurina.transitions.Tweener;
    public class FlashTest extends Sprite {
		
		
		private var sp:Sprite;
		private var bz:BezeirLine;
		private var p:Number = 0;
		private var points:Array = [];
		
		//setting
		private var colorArray:Array = [0x2A95BF,0x6CBAD9,0x015CA5,0x187DC1,0xD2D6D9,0xF2B90F,0xDFFF24,0x85DB18,0xFF358B];
		private var speed:Number = 0.02
		private var pointNum:Number = 10
		
        public function FlashTest() {
            bz = new BezeirLine();
			draw2DBezier()
        }
		
		private function getRandomPoints(num:int):void{
			//始点は画面左端
			points.push([0,Math.random()*stage.stageHeight])
			for(var i:int=0; i<num; i++){
				points.push([Math.random()*stage.stageWidth,Math.random()*stage.stageHeight])
			}
			//終点は画面右端
			points.push([stage.stageWidth,Math.random()*stage.stageHeight])
		}
		
		private function draw2DBezier():void{
			//初期化
			p=0;
			points = [];
			getRandomPoints(pointNum);
			bz.points = points;
			bz.getAnchorPoints();
			sp = new Sprite();
			addChild(sp);
			sp.graphics.lineStyle(1,0xCCCCCC)
			sp.graphics.moveTo(points[0][0],points[0][1])
			
			//描画開始
			addEventListener(Event.ENTER_FRAME,loop)
		}
		
		private function loop(e:Event):void{
			p += speed
			var bezierP:Array = bz.Bezeir2DPoints(p)
			if(bezierP[0]){
				if(Math.random() < 0.4){
					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]
				}
				sp.graphics.lineTo(bezierP[0],bezierP[1])
			}else{
				removeEventListener(Event.ENTER_FRAME,loop)
				draw2DBezier();
			}
		}
			
    }
	
}

import flash.display.*;
import flash.events.*;
class BezeirLine extends Sprite {
	
	public var t:Number = 0;
	public var points:Array;
	public var anchors:Array;
	
	function BezeirLine(){}
	
	public function getAnchorPoints():void{
		 anchors = [];		
		for(var i:int=0; i< points.length-1; i++){
			var hx:Number = (points[i][0] + points[i+1][0]) / 2;
			var hy:Number = (points[i][1] + points[i+1][1]) / 2;
			anchors[i] = [hx,hy];
		}		
	}
	
	public function Bezeir2DPoints(p:Number):Array{
		var currentPoint:int = Math.floor(p)
		p = p- currentPoint;
		
		var sx:Number
		var sy:Number
		var ex:Number
		var ey:Number
		var hx:Number
		var hy:Number
		
		if( currentPoint == 0 ){
		  sx = points[currentPoint][0];
		  sy = points[currentPoint][1];
		  ex = points[currentPoint+1][0];
		  ey = points[currentPoint+1][1];
		  hx = ( points[currentPoint+1][0] + points[currentPoint+2][0] ) / 2;
		  hy = ( points[currentPoint+1][1] + points[currentPoint+2][1] ) / 2;
		}else if ( currentPoint == points.length -3 ){		  
		  sx = ( points[currentPoint][0] + points[currentPoint+1][0] ) / 2;
		  sy = ( points[currentPoint][1] + points[currentPoint+1][1] ) / 2;
		  ex = points[currentPoint+1][0];
		  ey = points[currentPoint+1][1];
		  hx = points[currentPoint+2][0];
		  hy = points[currentPoint+2][1];
		}else if(currentPoint < points.length -3) {
		  sx = ( points[currentPoint][0] + points[currentPoint+1][0] ) / 2;
		  sy = ( points[currentPoint][1] + points[currentPoint+1][1] ) / 2;
		  ex = points[currentPoint+1][0];
		  ey = points[currentPoint+1][1];
		  hx = ( points[currentPoint+1][0] + points[currentPoint+2][0] ) / 2;
		  hy = ( points[currentPoint+1][1] + points[currentPoint+2][1] ) / 2;
		}else{
			return [null];
		}
		
		
		var xP:Number = (1-p)*(1-p)*sx + 2*p*(1-p)*ex + p*p*hx;
      	var yP:Number = (1-p)*(1-p)*sy + 2*p*(1-p)*ey + p*p*hy;
		
		return [xP,yP]
		
	}
	
}