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: Splouch by Grégoire Divaret

package, import, class definition added by mash
others are from 
http://www.25lines.com/finalists/0812/073.txt
// forked from mash's Bottle Glass Mountains
// package, import, class definition added by mash
// others are from 
// http://www.25lines.com/finalists/0812/073.txt
package {
	import flash.display.*;
	import flash.events.*;
	import flash.filters.*;
	import flash.geom.*;
	import flash.text.*;
	import flash.utils.*;    
	public class Splouch extends Sprite {
		public function Splouch() {

			// 3 free lines! Alter the parameters of the following lines or remove them.
			// Do not substitute other code for the three lines in this section
			[SWF(width=1000, height=500, backgroundColor=0xCCCCCC, frameRate=60)]
			//stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			// 25 lines begins here!
			//use your mouse, click!
			var tentacles:Array = [];
			var ran:Function = Math.random;
			var stw:int = stage.stageWidth;
			var r:Number;
			var sth:int = stage.stageHeight;
			var sh:Shape = new Shape();
			var bd:BitmapData = (addChild(new Bitmap(new BitmapData(stw, sth, true, 0xFFDEDEDE))) as Bitmap).bitmapData;
			var gr:int = 25 + Math.random() * 180;
			var gv:int = 25 + Math.random() * 180;
			var gb:int = 25 + Math.random() * 180;
			var hop:Boolean = true;
			for(var i:int = 0; i < 15; i++){
					  	tentacles.push(new tenta(
					  	stw/2,
					 	sth/2, 
					 	(mouseX - stw/2) / 100, 
					 	(mouseY - sth/2) / 100, 
					 	[],
					 	35 + ran() * 15, 
					 	true, 
					 	gr + ran() * 50,
					  	gv + ran() * 50, 
					  	gb + ran() * 50));
			}
			stage.addEventListener(MouseEvent.CLICK, function(e:Event):void{hop = !hop});
			addEventListener(Event.ENTER_FRAME, animate);
			function animate(e:Event):void
			{
			    bd.lock();
			    bd.fillRect(bd.rect, 0xFFDEDEDE);
			    for each (var t:Object in tentacles)
			    {
			        if(t.dir){
			        	t.vx += ran() * 4 - 2 + (mouseX - stw/2) / 2000;
			        	t.vx *=  0.95;
			        	t.vy += ran() * 4 - 2 + (mouseY - sth/2) / 2000;
			        	t.vy *=  0.95;
			        	t.pts.push({
			        		vx:0,
			         		vy:0,
			          		x:t.x += t.vx,
			           		y:t.y += t.vy});
			        }else {
			        	t.pts.splice(t.pts.length-1, 1);
			        }
			        sh.graphics.moveTo(t.pts[t.pts.length-1].x, t.pts[t.pts.length-1].y);
			        for(var i:int = t.pts.length-1; i >= 0 ; i--)
			        {
			        	r = i / t.pts.length;
			        	//var thick:Number = Math.pow((1 -  r) * 10, 2) * (100 - Math.abs(t.life)) / 100;
			        	var thick:Number = 1;
			            var color:uint =  (r)<<24 | (r*r * t.r) << 16 | (r * r * t.g) << 8 | (r*r * t.b);
			       	
			            sh.graphics.lineStyle(thick, color);
			            t.pts[i].vx += (hop ? r : 1-r) * (mouseX - t.pts[i].x) / 1500;
			            t.pts[i].vx *=  0.95;
						t.pts[i].x+= t.pts[i].vx;
		
			             t.pts[i].vy +=(hop ? r : 1-r) * (mouseY - t.pts[i].y) / 1500;
			             t.pts[i].vy *=  0.95;
			             t.pts[i].y+= t.pts[i].vy;
		
			            sh.graphics.lineTo(t.pts[i].x, t.pts[i].y);
	
			        }
			        bd.draw(sh);
			        sh.graphics.clear();
			        if((t.life-=0.5) <= 0 && t.dir){ t.dir = false;
			        }else if(!t.dir && t.pts.length <= 1){ 
				        tentacles[tentacles.indexOf(t)] = 
				        new tenta(
				       		t.pts[0].x, 
				        t.pts[0].y, 
				        t.pts[0].vx, 
				        t.pts[0].vy, 
				        [], 
				        35 + ran() * 15, 
				        true, 
				        gr + ran() * 50, 
				        gv + ran() * 50, 
				        gb + ran() * 50);
			        }
			    }
			    bd.unlock();
			}
		// 25 lines ends here!
		}
	}
}

class tenta{
	public var x:Number;
	public var y:Number;
	public var vx:Number;
	public var vy:Number;
	public var pts:Array;
	public var life:int;
	public var dir:Boolean;
	public var r:uint;
	public var g:uint;
	public var b:uint;
	//public var v:Number;
	public function tenta(x:Number,y:Number,vx:Number,vy:Number,
	pts:Array, life:int, dir:Boolean, r:uint, g:uint, b:uint){
		this.x = x;
		this.y = y;
		this.vx = vx;
		this.vy = vy;
		this.pts = pts;
		this.life = life;
		this.dir = dir;
		this.r = r;
		this.g = g;
		this.b = b;
	};	

}

;