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

3D plasma (anaglyph)

Anaglyph 3D plasma (yes, you're going to need glasses).

@author Zevan Rosser
@see http://actionsnippet.com/?p=562
Get Adobe Flash player
by makc3d 05 Aug 2009
package {
	import flash.display.*;
	import flash.events.*;
	import flash.filters.*;
	import flash.geom.*;

	[SWF(width=465, height=465, backgroundColor=0, frameRate=30)]
	/**
	* Anaglyph 3D plasma (yes, you're going to need glasses).
	* 
	* @author Zevan Rosser
	* @see http://actionsnippet.com/?p=562
	*/
	public class Plasma3D extends Sprite {
		private var left:BitmapData;
		private var right:BitmapData;
		private var displace:BitmapData;
		private var displacementMap:DisplacementMapFilter;
		private var offsets:Array;


		public function Plasma3D () {
			left = new BitmapData(465, 465, true, 0xFF000000);
			var leftBmp:Bitmap = new Bitmap (left);
			leftBmp.transform.colorTransform = new ColorTransform (1, 0, 0);
			addChild(leftBmp);

			right = new BitmapData(465, 465, true, 0xFF000000);
			var rightBmp:Bitmap = new Bitmap (right);
			rightBmp.transform.colorTransform = new ColorTransform (0, 1, 1);
			rightBmp.blendMode = BlendMode.ADD;
			addChild(rightBmp);

			displace = new BitmapData(465, 465, false, 0xFF000000);
			displacementMap = new DisplacementMapFilter(displace, new Point(0, 0), 1, 1,  0, 0, DisplacementMapFilterMode.CLAMP);

			offsets = [new Point, new Point, new Point];

			addEventListener(Event.ENTER_FRAME, onLoop);
		}

		private function onLoop(evt:Event):void {
			Point (offsets [0]).y += 3; Point (offsets [0]).x -=1;
			Point (offsets [1]).y += 2; Point (offsets [1]).x +=2;
			Point (offsets [2]).y += 1; Point (offsets [2]).x -=3;

			displace.perlinNoise(150, 150, 3, 30, true, false, 0, true, offsets);
			displace.draw(displace, null , null, BlendMode.INVERT);
			displacementMap.mapBitmap = displace;

			// left eye
			left.copyPixels(displace, left.rect, left.rect.topLeft);
			displacementMap.scaleX = -25;
			left.applyFilter(left, left.rect, left.rect.topLeft, displacementMap);

			// right eye
			right.copyPixels(displace, right.rect, right.rect.topLeft);
			displacementMap.scaleX = +25;
			right.applyFilter(right, right.rect, right.rect.topLeft, displacementMap);
		}
	}
}