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

forked from: entropy

Get Adobe Flash player
by Susisu 02 Sep 2010
// forked from Susisu's entropy
package {
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.events.Event;
    import flash.display.Sprite;
    import flash.geom.Point;
    import net.hires.debug.Stats;
    [SWF(width="465", height="465", backgroundColor="0x000000", frameRate="60")]
    public class FlashTest extends Sprite {
        public var particles:Vector.<Particle>=new Vector.<Particle>();
        public var canvas:BitmapData=new BitmapData(465,465,false);
        public var bmp:Bitmap=new Bitmap(canvas);
        public var cp:Point=new Point(465/2,465/2);
        public var gpoints:Vector.<Point>=new Vector.<Point>();
        public function FlashTest() {
            for(var i:int=0;i<100;i++){
                for(var j:int=0;j<100;j++){
                    var r:Number=Math.random()*2*Math.PI;
                    particles.push(new Particle(i+cp.x-50,j+cp.y-50,Math.cos(r),Math.sin(r)));
                }
            }
            for(i=0;i<360;i+=120){
                gpoints.push(new Point(Math.cos(i/180*Math.PI)*120+cp.x,Math.sin(i/180*Math.PI)*120+cp.y));
            }
            gpoints.push(cp);
            addChild(bmp);
            addEventListener(Event.ENTER_FRAME,onEnterFrame);
            addChild(new Stats());
        }
        public function onEnterFrame(e:Event):void{
            canvas.lock();
            canvas.fillRect(canvas.rect,0);
            var dx:Number,dy:Number;
            var d2:Number;
            var j:int;
            for(var i:int=0;i<10000;i++){
                particles[i].x+=particles[i].vx;
                particles[i].y+=particles[i].vy;
                for(j=0;j<4;j++){
                    dx=gpoints[j].x-particles[i].x;
                    dy=gpoints[j].y-particles[i].y;
                    d2=dx*dx+dy*dy
                    particles[i].vx+=dx/d2;
                    particles[i].vy+=dy/d2;
                }
                canvas.setPixel32(particles[i].x>>0,particles[i].y>>0,0xffffff);
            }
            canvas.unlock();
        }
    }
}
import flash.geom.Point;
class Particle{
    public var x:Number=0;
    public var y:Number=0;
    //public var v:Point=new Point(0,0);
    public var vx:Number=0;
    public var vy:Number=0;
    public function Particle(x:Number,y:Number,vx:Number,vy:Number){
        this.x=x;
        this.y=y;
        this.vx=vx;
        this.vy=vy;
    }
}