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: Yet another plasma

Based on image by stretchMarx
http://www.fractalforums.com/meet-and-greet/hello-with-pics/
Get Adobe Flash player
by makc3d 27 Jan 2010
package
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.net.URLRequest;
	import flash.system.LoaderContext;

	// Based on image by stretchMarx
	// http://www.fractalforums.com/meet-and-greet/hello-with-pics/

	[SWF(width=465,height=465,frameRate=60)]
	public class Plasma extends Sprite {

		protected var palette_r:Array = [];
		protected var palette_g:Array = [];
		protected var palette_b:Array = [];
		protected var bmd_0:BitmapData;
		protected var bmd_1:BitmapData;
		protected var loader:Loader;

		public function Plasma () {
			loader = new Loader;
			loader.contentLoaderInfo.addEventListener (Event.COMPLETE, init);
			loader.load (new URLRequest ("http://assets.wonderfl.net/images/related_images/4/41/41f6/41f69a2ac7ce3446f6c7a38fa0bfd74cc75d91a7"), new LoaderContext (true));
		}

		public function init (e:Event):void {
			bmd_0 = loader.content ["bitmapData"];
			bmd_1 = bmd_0.clone (); addChild ( new Bitmap( bmd_1 ) );

			var x:int, y:int;
			// need better colors, someone!
			for( x = 0; x < 256; x++ ) {
				palette_r [x] = 0x10000 * int(128.0 + 128 * Math.sin(3.1415 * x / 256.0));
				palette_g [x] =   0x100 * int(128.0 + 128 * Math.sin(3.1415 * x / 128.0));
				palette_b [x] =       1 * int(128.0 + 128 * Math.sin(3.1415 * x /  64.0));
			}

			addEventListener( Event.ENTER_FRAME, enterFrameHandler );
		}

		protected function enterFrameHandler( event : Event = null ):void {
			// now, let's do things right way
			var shift : int = 1;
			while (shift -- > 0) {
				palette_r.push (palette_r.shift ());
				palette_g.push (palette_g.shift ());
				palette_b.push (palette_b.shift ());
			}
			bmd_1.paletteMap (bmd_0, bmd_0.rect, bmd_0.rect.topLeft, palette_r, palette_g, palette_b);
		}

	}
	
}