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

Menger sponge

package {
	import flash.display.*;
	import flash.events.*;
	import flash.net.*;
    import sandy.core.*;
    import sandy.core.data.*;
    import sandy.core.scenegraph.*;
    import sandy.primitive.*;
    import sandy.materials.*;
    import sandy.view.*;
	[SWF(width=465,height=465)]
	public class MengerSponge extends BasicView {
		public function MengerSponge () {
			super (); init (465, 465);
			sphere = new Sphere ("menger", 123, 24, 24);
			sphere.enableBackFaceCulling = false;
			sphere.enableClipping = true;
			rootNode.addChild (sphere);
			camera.z = 0; camera.fov = 90; camera.near = 1e-3;
			stage.quality = "low";

			// load Menger sponge map by by Angelo "KeN" Pesce, 2001
			var loader:Loader = new Loader;
			loader.contentLoaderInfo.addEventListener (Event.COMPLETE, onLoaded);
			loader.contentLoaderInfo.addEventListener (ProgressEvent.PROGRESS, onProgress);
			loader.load (new URLRequest ("http://local.wasp.uwa.edu.au/~pbourke/fractals/gasket/inside.gif"));

			Wonderfl.capture_delay( 10 );
		}
		override public function simpleRender(pEvt:Event = null):void {
			sphere.pan += 1.0; sphere.roll += 0.5; super.simpleRender (pEvt);
		}
		private function onProgress (e:ProgressEvent):void {
			graphics.clear ();
			graphics.lineStyle (2);
			graphics.drawRect (80, 220, 304, 34);
			graphics.lineStyle ();
			graphics.beginFill (0);
			graphics.drawRect (82, 222, 300 * e.bytesLoaded / (e.bytesTotal + 1e-4), 30);
			graphics.endFill ();
		}
		private function onLoaded (e:Event):void {
			graphics.clear ();
			var li:LoaderInfo = LoaderInfo (e.target);
			// abuse security hole in FP10
			// http://wonderfl.net/code/13ee977b48920d779444c516cf7b220df5ab21b5
			var loader:Loader = new Loader;
			loader.contentLoaderInfo.addEventListener (Event.COMPLETE, onReady);
			loader.loadBytes (li.bytes);
		}
		private function onReady (e:Event):void {
			var li:LoaderInfo = LoaderInfo (e.target);
			var bd:BitmapData = new BitmapData (li.content.width, li.content.height, false, 0xffffff);
			bd.draw (li.content); sphere.appearance = makeBitmapAppearance (bd); render ();
		}
		private var sphere:Sphere;
	}
}