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: forked from: forked from: particle 煙っぽい

@author sph62

KonKiKi
改造させて頂きました。

[SWF(backgroundColor="0x000000",width="800",height="800",frameRate="30")]
Get Adobe Flash player
by ueueueueue 23 May 2009
// forked from ueue's forked from: forked from: particle _ 星間飛行?
// forked from KonKiKi's forked from: particle _ 星間飛行?
// forked from sph62's particle
package  {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
        import flash.filters.BlurFilter;
        import net.hires.debug.Stats; 
        
        /**
         *
         * @author sph62
         */
        /*KonKiKi
            改造させて頂きました。
        */
        import flash.display.Bitmap;
        import flash.display.BitmapData;
        import flash.geom.*;

	//[SWF(backgroundColor="0x000000",width="800",height="800",frameRate="30")]         
        public class Main extends Sprite {
		
		private var particles:Array;
		private var numParticles:uint = 20;
		private var minDist:Number = 200;
		private var springAmount:Number =  .001;
		
        //konKiKi
        private var space:Sprite;
        private var bmp:BitmapData;
        private var cxform:ColorTransform;

                
		public function Main() {
			init();
                        addChild(new Stats());
		}
		
		private function init():void {
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			
            //KonKiKi
            bmp = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0);
            cxform = new ColorTransform(1,1,1,0.98);
            addChild( new Bitmap(bmp) );
			
			space = new Sprite();
			addChild(space);


			particles = new Array();
			for (var i:uint = 0; i < numParticles; i++) {
				var size:Number = Math.random() * 10 + 2;
				var particle:Ball = new Ball(size);
				particle.x = Math.random() * stage.stageWidth;
				particle.y = Math.random() * stage.stageHeight;
				particle.vx = Math.random() * 2 - 1;
				particle.vy = Math.random() * 3 - 1;
				particle.mass = size;
				addChild(particle);
				particles.push(particle);
			}

			addEventListener(Event.ENTER_FRAME, onEnterFrame);
			
		}
		
		private function onEnterFrame(event:Event):void {
			for (var i:uint = 0; i < numParticles; i++) {
				var particle:Ball = particles[i];
				particle.x += particle.vx;
				particle.y += particle.vy;
				border(particle);
			}
			space.graphics.clear();

			for (i = 0; i < numParticles - 1; i++ ) {
				var partA:Ball = particles[i];
				for (var j:uint = i + 1; j < numParticles; j++ ) {
					var partB:Ball = particles[j];
					spring(partA, partB);

				}
			}
            //KonKiKi
            drawSpace();	
		}
		private function spring(partA:Ball, partB:Ball):void {
			var dx:Number = partB.x - partA.x;
			var dy:Number = partB.y - partA.y;
			var distSQ:Number = dx * dx + dy * dy;
			var dist:Number = Math.sqrt(distSQ);
			if (dist < minDist) {
				space.graphics.lineStyle(1,0x666666,1-dist/(minDist*0.7));
				space.graphics.moveTo(partA.x, partA.y);
				space.graphics.lineTo(partB.x, partB.y);
                                space.filters = [new BlurFilter(30,30,1)];
                                space.blendMode ="add";
				var ax:Number = dx * springAmount;
				var ay:Number = dy * springAmount;
				partA.vx += ax / partA.mass;
				partA.vy += ay / partA.mass;
				partB.vx -= ax / partB.mass;
				partB.vy -= ay / partB.mass;
			}
			
		}
		private function border(particle:Ball):void {
			if (particle.x >= stage.stageWidth || particle.x <= 0) {
				particle.vx = -particle.vx;
			}
			if (particle.y >= stage.stageHeight || particle.y <= 0) {
				particle.vy = -particle.vy;
			}
		}
		/*
		private function gravitate(partA:Ball, partB:Ball):void {
			var dx:Number = partB.x - partA.x;
			var dy:Number = partB.y - partA.y;
			var distSQ:Number = dx * dx + dy * dy;
			var dist:Number = Math.sqrt(distSQ);
			var force:Number = partA.mass * partB.mass / distSQ;
			var ax:Number = force * dx / dist;
			var ay:Number = force * dy / dist;
			partA.vx += ax / partA.mass;
			partA.vy += ay / partA.mass;
			partB.vx -= ax / partB.mass;
			partB.vy -= ay / partB.mass;
		}
		*/
        //KonKiKi
        private function drawSpace():void{
			bmp.lock();
			bmp.colorTransform(bmp.rect,cxform);
			bmp.draw(stage);
			bmp.unlock();
		}
	}
	
}

import flash.display.Sprite;

class Ball extends Sprite {
	public var _radius:Number;
	public var _color:uint;

	public var mass:Number = 0;
	
	public var vx:Number = 0;
	public var vy:Number = 0;
	
	public function Ball(radius:Number = 1, color:uint = 0xFFFFFF) {
		this._radius = radius;
		this._color = color;
		this.mass = radius * 5;
                this.alpha =0;
			
		init();
			
	}
		
	private function init():void {
		graphics.beginFill(_color, 1);
		graphics.drawCircle(0, 0, 1);
		graphics.endFill();		
	}
}