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

Joshua的ベジェ

Get Adobe Flash player
by keno42 03 May 2009
package {
    import flash.display.*;
    import flash.geom.*;
    import flash.events.*;
    public class FlashTest extends Sprite {
        private var bmpData:BitmapData = new BitmapData(465, 465, true, 0xFF000000);
        private var x1:Point = new Point(50, 50);
        private var x2:Point = new Point(300, 50);
        private var x3:Point = new Point(115, 415);
        private var x4:Point = new Point(415, 415);
        public function FlashTest() {
            // write as3 code here..
            addChild(new Bitmap(bmpData));
            this.addEventListener(Event.ENTER_FRAME,onEnterFrame);
        }
        private var count:int = 0;
        private function onEnterFrame(e:Event):void{
            if( (count & 3) == 0 ){
                var p:Piece = new Piece(bmpData);
                p.blendMode = BlendMode.ADD;
                this.addChild( p );
                p.SetAndStart(x1, x2, x3, x4);
            }
            if( ++count >= (1 << 8) ){
                this.removeEventListener(Event.ENTER_FRAME,onEnterFrame);
            }
        }
    }

}
import flash.display.*;
import flash.geom.*;
import flash.events.*;
class Piece extends Sprite{
    private var t:Number = 1.5;
    private const d:Number = 1 / (1 << 8);
    private var x1:Point = new Point(50, 50);
    private var x2:Point = new Point(300, 50);
    private var x3:Point = new Point(115, 415);
    private var n2:Point = new Point(300, 50);
    private var n3:Point = new Point(115, 415);
    private var x4:Point = new Point(415, 415);
    private var bmpData:BitmapData;
    public function Piece(bd:BitmapData){
        bmpData = bd;
        this.graphics.beginFill(Math.random()*0xFFFFFF, 0.3);
        this.graphics.drawCircle(0, 0, Math.random() * 5);
        this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
        this.visible = false;
    }
    public function SetAndStart(x1:Point, x2:Point, x3:Point, x4:Point):void{
        t = 2;
        this.x1 = x1;
        this.x2 = x2;
        this.x3 = x3;
        this.x4 = x4;
    }
    private function onEnterFrame(e:Event):void{
        if( t <= 1.0 ){
            this.visible = true;
            var s:Number = (1-t);
            x = s*s*s*x1.x+t*(3*s*s*n2.x+t*(3*s*n3.x+t*x4.x));
            y = s*s*s*x1.y+t*(3*s*s*n2.y+t*(3*s*n3.y+t*x4.y));
            t += d;
            scaleX = 20*(0.5-Math.abs(0.5-t));
            scaleY = 20*(0.5-Math.abs(0.5-t));
           // bmpData.draw(this, new Matrix(scaleX,0,0,scaleY,x,y));
        } else {
            t = 0;
            n2 = x2.add( new Point( 50 - 100 * Math.random(), 50 - 100 * Math.random() ) );
            n3 = x3.add( new Point( 50 - 100 * Math.random(), 50 - 100 * Math.random() ) );
            this.visible = false;
        }
    }
}