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

Sludge

勢いのみで、全然最適化してないです(所々やや重い)
@author ue
Get Adobe Flash player
by _ueueueueue 15 Apr 2010
/**
 * Copyright _ueueueueue ( http://wonderfl.net/user/_ueueueueue )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/tlSb
 */

package 
{
	import flash.display.*;
	import flash.events.*;
	import flash.filters.BlurFilter;
	import flash.geom.*;
	import flash.text.*;
	import flash.ui.*;
	import net.hires.debug.Stats;
	
	[SWF(backgroundColor=0xFFFFFF)]
	
	/**
	 * 勢いのみで、全然最適化してないです(所々やや重い)
	 * @author ue
	 */
	
	public class Main extends Sprite 
	{
		private const NUM:int = 50;
		
		private var container:Sprite;
		private var balls:Vector.<Ball>;
		private var divide:Number = 1200;
		
		public function Main():void 
		{
			container = new Sprite();
			container.x = stage.stageWidth / 2;
			container.y = stage.stageHeight / 2;
			container.z = 0;
			addChild(container);
			
			balls = new Vector.<Ball>(NUM, true);
			for (var i:int = 0; i < NUM; i++) 
			{
				var ball:Ball = new Ball();
				ball.x = Math.random() * 120 - 60;
				ball.y = Math.random() * 120 - 60;
				ball.z = Math.random() * 120 - 60;
				ball.vx = Math.random() * 2 - 1;
				ball.vy = Math.random() * 2 - 1;
				//ball.vz = Math.random() * 4 - 2;
				ball.blendMode = BlendMode.DIFFERENCE;
				ball.filters = [new BlurFilter(10,10)];
				container.addChild(ball);
				balls[i] = ball;
			}
			addEventListener(Event.ENTER_FRAME, update);
			
			addChild(new Stats());
		}
		
		private function update(e:Event):void 
		{
			//balls.sort(depth);
			for (var i:int = 0; i < NUM; i++) 
			{
				var ball:Ball = balls[i];
				//container.addChildAt(ball, i);
				
				var dx:Number = 0 - ball.x;
				var dy:Number = 0 - ball.y;
				var dist:Number = Math.sqrt(dx * dx + dy * dy);
				
				if (ball.x > 0) ball.vx -= dist / divide;
				else ball.vx += dist / divide;
				if (ball.y > 0) ball.vy -= dist / divide;
				else ball.vy += dist / divide;
				//if (ball.z > 0) ball.vz -= dist / divide;
				//else ball.vz += dist / divide;
				
				ball.x += ball.vx;
				ball.y += ball.vy;
				//ball.z += ball.vz;
			}
		}
		
		//private function depth(a:Ball, b:Ball):int
		//{
			//var aPos:Vector3D =  a.transform.matrix3D.position;
			//aPos = container.transform.matrix3D.deltaTransformVector(aPos);
			//var bPos:Vector3D =  b.transform.matrix3D.position;
			//bPos = container.transform.matrix3D.deltaTransformVector(bPos);
			//return bPos.z - aPos.z;
		//}
	}
}

import flash.display.Sprite;
import flash.display.Stage;

class Ball extends Sprite
{
	public var vx:Number;
	public var vy:Number;
	public var vz:Number;
	public function Ball()
	{
		var element:uint = Math.random() * 128 + 50; 
		graphics.beginFill(element << 16 | element << 8 | element);
		graphics.drawCircle(0, 0, Math.random() * 40 + 10);
		graphics.endFill();
	}
}