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

湧き出るいくら(60FPS)

余裕のある方はどうぞ
Get Adobe Flash player
by Susisu 06 Mar 2011
// forked from Susisu's 湧き出るいくら
// forked from Susisu's flash on 2011-3-5
package {
    import flash.geom.Point;
    import flash.display.Shape;
    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;
        private var circle:BitmapData;
        private var crect:Rectangle;
        private const point0:Point=new Point(0,0);
        public function FlashTest() {
            canvas=new BitmapData(465,465,true,0);
            rect=canvas.rect;
            bmp=new Bitmap(canvas);
            addChild(bmp);
            var s:Shape=new Shape();
            s.graphics.beginFill(0xff8000);
            s.graphics.drawCircle(8,8,8);
            s.graphics.endFill();
            s.graphics.beginFill(0xc03000);
            s.graphics.drawCircle(8,4,4);
            s.graphics.endFill();
            s.graphics.beginFill(0xffffff);
            s.graphics.drawCircle(4,4,2);
            s.graphics.endFill();
            circle=new BitmapData(16,16,true,0);
            circle.draw(s);
            crect=circle.rect;
            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<300;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;
            var point:Point=new Point(0,0);
            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*0.2;
                }
                else if(x>465-16){
                    p.x=465-16;
                    p.vx=-p.vx*0.2;
                }
                if(y<0){
                    p.y=0;
                    p.vy=-p.vy*0.2;
                }
                else if(y>465-16){
                    p.y=465-16;
                    p.vy=-p.vy*0.2;
                }
                var q:Particle=first;
                while(q){
                    var dx:Number=x-q.x;
                    var dy:Number=y-q.y;
                    var d:Number=dx*dx+dy*dy;
                    
                    if(p!=q&&d<256){
                        p.vx=dx*0.2;
                        p.vy=dy*0.2;
                        q.vx=-dx*0.2;
                        q.vy=-dy*0.2;
                    }
                    q=q.next;
                }
                p.vx*=0.9;
                p.vy*=0.9;
                if(x>200&&x<265)p.vy-=0.98
                else p.vy+=0.98
                //canvas.setPixel32(p.x>>0,p.y>>0,0xff000000);
                point.x=p.x;
                point.y=p.y;
                canvas.copyPixels(circle,crect,point,circle,point0,true);
                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
    }
}