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

3Dへにょり

ひつまぶし
Get Adobe Flash player
by Susisu 10 Apr 2011
    Embed
package {
    import flash.events.Event;
    import flash.display.Sprite;
    import flash.display.BlendMode;
    import net.hires.debug.Stats;
    [SWF(width="512",height="512",backgroundColor="0x000000",frameRate="30")]
    public class FlashTest extends Sprite {
        private var c:uint;
        private var f:uint;
        public function FlashTest() {
            c=0;
            f=0;
            addChild(new Stats());
            addEventListener(Event.ENTER_FRAME,onEnterFrame);
        }
        private function onEnterFrame(e:Event):void{
            if(f%20==0){
                var curve:Curve=new Curve();
                curve.x=curve.y=256;
                curve.blendMode="layer";
                addChild(curve);
                c++;
            }
            if(c>10)removeEventListener(Event.ENTER_FRAME,arguments.callee);
            f++;
        }

    }
}
import flash.display.Sprite;
import flash.display.Graphics;
import flash.events.Event;
import frocessing.color.ColorHSV;
class Curve extends Sprite{
    private var i:Number;
    private var g:Graphics3D;
    private var t:Number;
    private var d:int;
    private var color:ColorHSV;
    private var spr:Sprite;
    public function Curve(){
        spr=new Sprite();
        g=new Graphics3D(spr);
        color=new ColorHSV();
        addChild(spr);
        init();
    }
    private function init():void{
        i=0;
        color.h=Math.random()*0xffffff>>0;
        g.clear();
        g.lineStyle(20,color.value,1);
        g.moveTo(0,0,500);
        t=Math.random()*2*Math.PI;
        d=Math.random()*2>>0?1:-1;
        addEventListener(Event.ENTER_FRAME,onEnterFrame);
    }

    private function onEnterFrame(e:Event):void{
        g.lineTo(Math.cos(i+t)*Math.abs(i)*10,Math.sin(i+t)*Math.abs(i)*10,500-Math.abs(i)*100);
        i+=d*Math.PI/20;
        if(Math.abs(i)>2.2*Math.PI){
            removeEventListener(Event.ENTER_FRAME,onEnterFrame);
            addEventListener(Event.ENTER_FRAME,fadeout);
        }
    }
    private function fadeout(e:Event):void{
        alpha-=0.02;
        if(alpha<=0){
            alpha=1;
            removeEventListener(Event.ENTER_FRAME,fadeout);
            init();
        }
    }

}

class Graphics3D{
    private var g:Graphics;
    private var thickness:Number=0;
    private var lineColor:uint=0;
    private var lineAlpha:Number=1.0;
    private var lineStartX:Number=0;
    private var lineStartY:Number=0;
    private var lineStartZ:Number=0;
    private const VS:Number=200;
    public function Graphics3D(target:Sprite){
        g=target.graphics;
    }
    public function clear():void{
        g.clear();
    }
    public function lineStyle(thickness:Number,color:uint=0,alpha:Number=1.0):void{
        this.thickness=thickness;
        this.lineColor=color;
        this.lineAlpha=alpha;
    }
    public function moveTo(x:Number,y:Number,z:Number):void{
        this.lineStartX=x;
        this.lineStartY=y;
        this.lineStartZ=z;
    }
    public function lineTo(x:Number,y:Number,z:Number):void{
        var p:Number=VS/(VS+this.lineStartZ);
        g.beginFill(lineColor,lineAlpha);
        var startThickness:Number=thickness*p/2;
        var startX:Number=this.lineStartX*p;
        var startY:Number=this.lineStartY*p;
        g.drawCircle(startX,startY,startThickness);
        g.endFill();
        g.beginFill(lineColor,lineAlpha);
        p=VS/(VS+z);
        var endThickness:Number=thickness*p/2;
        var endX:Number=x*p;
        var endY:Number=y*p;
        g.drawCircle(endX,endY,endThickness);
        g.endFill();
        g.beginFill(lineColor,lineAlpha);
        var rX:Number=endX-startX;
        var rY:Number=endY-startY;
        var dT:Number=startThickness-endThickness;
        var t:Number=rX*rX+rY*rY;
        var dT2:Number=dT*dT;
        g.moveTo(startX+startThickness*(rX*dT+rY*Math.sqrt(t-dT2))/t
                ,startY+startThickness*(rY*dT-rX*Math.sqrt(t-dT2))/t);
        g.lineTo(startX+startThickness*(rX*dT-rY*Math.sqrt(t-dT2))/t
                ,startY+startThickness*(rY*dT+rX*Math.sqrt(t-dT2))/t);

        g.lineTo(endX+endThickness*(rX*dT-rY*Math.sqrt(t-dT2))/t
                ,endY+endThickness*(rY*dT+rX*Math.sqrt(t-dT2))/t);
        g.lineTo(endX+endThickness*(rX*dT+rY*Math.sqrt(t-dT2))/t
                ,endY+endThickness*(rY*dT-rX*Math.sqrt(t-dT2))/t);

        g.endFill();
        moveTo(x,y,z);
    }
}