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

flash on 2011-4-16

Get Adobe Flash player
by Susisu 16 Apr 2011
package {
    import flash.display.Sprite;
    [SWF(width="480",height="360",backgroundColor=0xffffff)]
    public class FlashTest extends Sprite {
        public function FlashTest() {
            var spr:Sprite=new Sprite();
            spr.x=240;
            spr.y=180;
            addChild(spr);
            var g:Graphics3D=new Graphics3D(spr);
            g.lineStyle(50,0);
            g.moveTo(240,-180,8191);
            g.curveTo(800,50,0,-150,100,0);
            g.moveTo(-200,-300,8191);
            g.curveTo(-900,-10,0,200,180,0);
        }
    }
}

    import flash.display.Sprite;
    import flash.display.Graphics;
    class Graphics3D{
        private var g:Graphics;
        private var thickness:Number=0;
        private var lineColor:uint=0;
        private var lineAlpha:Number=1.0;
        private var startX:Number=0;
        private var startY:Number=0;
        private var startZ:Number=0;
        public var vs:Number=-200;
        public function Graphics3D(target:Sprite,vs:Number=-200){
            this.g=target.graphics;
            this.vs=vs;
        }
        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.startX=x;
            this.startY=y;
            this.startZ=z;
        }
        public function lineTo(x:Number,y:Number,z:Number):void{
            //g.lineStyle(undefined);
            var p:Number=-vs/(-vs+this.startZ);
            g.beginFill(lineColor,lineAlpha);
            var r1:Number=this.thickness*p/2;
            var startX:Number=this.startX*p;
            var startY:Number=this.startY*p;
            g.drawCircle(startX,startY,r1);
            g.endFill();
            g.beginFill(lineColor,lineAlpha);
            p=-vs/(-vs+z);
            var r2:Number=thickness*p/2;
            var endX:Number=x*p;
            var endY:Number=y*p;
            g.drawCircle(endX,endY,r2);
            g.endFill();
            g.beginFill(lineColor,lineAlpha);
            var s:Number=endX-startX;
            var t:Number=endY-startY;
            var u:Number=Math.asin((r1-r2)/Math.sqrt(s*s+t*t));
            var v:Number=Math.atan2(s,t);
            var a1:Number=u-v;
            var a2:Number=Math.PI-u-v;
            //g.lineStyle(0,0xff0000);
            g.moveTo(r1*Math.cos(a1)+startX,r1*Math.sin(a1)+startY);
            g.lineTo(r1*Math.cos(a2)+startX,r1*Math.sin(a2)+startY);
            g.lineTo(r2*Math.cos(a2)+endX,r2*Math.sin(a2)+endY);
            g.lineTo(r2*Math.cos(a1)+endX,r2*Math.sin(a1)+endY);
            g.endFill();
            moveTo(x,y,z);
        }
        public function curveTo(controlX:Number,controlY:Number,controlZ:Number,anchorX:Number,anchorY:Number,anchorZ:Number):void{
            var startX:Number=this.startX;
            var startY:Number=this.startY;
            var startZ:Number=this.startZ;
            for(var i:Number=0;i<=1;i+=0.01){
                var j:Number=1-i;
                var tX:Number=j*(j*startX+i*controlX)+i*(j*controlX+i*anchorX);
                var tY:Number=j*(j*startY+i*controlY)+i*(j*controlY+i*anchorY);
                var tZ:Number=j*(j*startZ+i*controlZ)+i*(j*controlZ+i*anchorZ);
                lineTo(tX,tY,tZ);
            }
        }
    }