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-3-5

Get Adobe Flash player
by Susisu 06 Mar 2011
package {
    import flash.geom.Rectangle;
    import flash.events.Event;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import net.hires.debug.Stats;
    [SWF(frameRate="60")]
    public class FlashTest extends Sprite {
        private var first:Particle;
        private var canvas:BitmapData;
        private var bmp:Bitmap;
        private var rect:Rectangle;
        public function FlashTest() {
            canvas=new BitmapData(465,465,true,0);
            rect=canvas.rect;
            bmp=new Bitmap(canvas);
            addChild(bmp);
            var r:Number=Math.random()*2*Math.PI;
            first=new Particle(Math.random()*465>>0,Math.random()*465>>0,Math.cos(r),Math.sin(r));
            var prev:Particle=first;
            for(var i:int=0;i<100000;i++){
                r=Math.random()*2*Math.PI;
                var next:Particle=new Particle(Math.random()*465>>0,Math.random()*465>>0,Math.cos(r),Math.sin(r));
                prev.next=next;
                prev=next;
            }
            addEventListener(Event.ENTER_FRAME,enterFrame);
            addChild(new Stats());
        }
        private function enterFrame(e:Event):void{
            canvas.lock();
            canvas.fillRect(rect,0);
            var p:Particle=first;
            while(p){
                var x:Number=p.x+=p.vx;
                var y:Number=p.y+=p.vy;
                if(x<0){
                    p.x=0;
                    p.vx=-p.vx;
                }
                else if(x>465){
                    p.x=465;
                    p.vx=-p.vx;
                }
                if(y<0){
                    p.y=0;
                    p.vy=-p.vy;
                }
                else if(y>465){
                    p.y=465;
                    p.vy=-p.vy;
                }
                canvas.setPixel32(p.x>>0,p.y>>0,0xff000000);
                p=p.next;
            }

            canvas.unlock();
        }

    }
}
class Particle{
    public var x:Number,y:Number,vx:Number,vy:Number,next:Particle;
    public function Particle(x:Number,y:Number,vx:Number,vy:Number){
        this.x=x;
        this.y=y;
        this.vx=vx;
        this.vy=vy;
        next=null
    }
}