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

code on 2008-12-30

Get Adobe Flash player
by 2ndyofyyx 01 Jan 2009
package {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Loader;
import flash.display.Shader;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.filters.ShaderFilter;
import flash.geom.Matrix;
import flash.geom.Point;
import flash.geom.Rectangle;
[SWF(width="465", height="465", frameRate="4")]
public class PNGTest extends Sprite {
	private static const SAMPLE_PNG:String = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAABD0lEQVRYCe2UaxLDIAiE+zp7D9mTdPrmS7spY9Uk2vyDGSJBlkVC3GxCogPRgehAfweu/SnaMhwNdjd9tMH7URBTBCuFYC+W7WLEFwDxzvT2cWEjT9P9YK344MQihoZ3CYX5Pfn/tp4tEyReIPSkq85GSq5CfAH4eCe2FE9Mk5QS+s/gE1cL0eB4QM2G/FII4D7IFXcwPzwMJ/td90bplJZ3EE5b+x0pIP1Ub+SMJ0AGsCa6F3IxkOc6lIv98UE8dXqBcn8Je83kLeC0YMjnHgC+UdTSqdaPAGeIUDnc1jxTrdRQsZLUq/ZyGYXn9LW4HHbwASQJygCmE05SfBSkFnsbH3oyDYkORAeiA8UOvACR6lmd4UhkVQAAAABJRU5ErkJggg==";
	private static const HEATBLUR_PBJ:String = "pQEAAACkCABIZWF0Qmx1cqAMbmFtZXNwYWNlAGpwLnl5eC4ybmR5LnBiawCgDHZlbmRvcgAybmR5b2Z5eXgAoAh2ZXJzaW9uAAEAoQECAAAMX091dENvb3JkAKMABHNyYwChAgQBAA9kc3QAMgAAIAAAAAAyAgCAv4AAADICAEAAAAAAHQIAMQAAEAABAgAxAgAQADADAPECALAAAQAAIAMAAAAyAgCAAAAAADICAEAAAAAAHQIAMQAAEAABAgAxAgAQADADAPECALAAAQAAIAMAAAAyAgCAP4AAADICAEAAAAAAHQIAMQAAEAABAgAxAgAQADADAPECALAAAQAAIAMAAAAyAgCAAAAAADICAEA/gAAAHQIAMQAAEAABAgAxAgAQADADAPECALAAAQAAIAMAAAAyAAAQPn4AAAMAACAAAMAAHQEAgAAAgAAyAQAQP4AAAA==";

	private var heat1:BitmapData = new BitmapData(465, 465, false);
	private var heat2:BitmapData = new BitmapData(465, 465, false);
	private var buffer:BitmapData = new BitmapData(465, 465, false);
	private var shaderFilter:ShaderFilter;
	public function PNGTest() {
		var root:Sprite = new Sprite();
		root.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
		root.addChild(new Bitmap(buffer));
		addChild(root);

		addEventListener(Event.ENTER_FRAME, onEnterFrame);

		var loader:Loader = new Loader();
		loader.loadBytes(new Base64(SAMPLE_PNG));
		loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);

		shaderFilter = new ShaderFilter(new Shader(new Base64(HEATBLUR_PBJ)));
	}
	private function onLoadComplete(event:Event) : void {
		var loader:Loader = Loader(event.target.loader);
		var bitmap:Bitmap = Bitmap(loader.content);
		var matrix:Matrix = new Matrix();
		matrix.scale(8, 8);
		heat1.draw(bitmap.bitmapData, matrix);
	}
	private function onEnterFrame(event:Event) : void {
		heat2.applyFilter(heat1, heat1.rect, new Point(), shaderFilter);
		var tmp:BitmapData = heat1;
		heat1 = heat2;
		heat2 = tmp;
		buffer.applyFilter(heat1, heat1.rect, new Point(), shaderFilter);
	}
	private function onMouseDown(event:MouseEvent) : void {
		heat1.fillRect(new Rectangle(128, 128, 128, 128), 0xffffffff);
	}
}
}
import flash.utils.ByteArray;
class Base64 extends ByteArray {
	private static const BASE64:Array = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,62,0,0,0,63,52,53,54,55,56,57,58,59,60,61,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,0,0,0,0,0,0,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,0,0,0,0,0];
	public function Base64(str:String) {
		var n:int, j:int;
		for(var i:int = 0; i < str.length && str.charAt(i) != "="; i++) {
			j = (j << 6) | BASE64[str.charCodeAt(i)];
			n += 6;
			while(n >= 8) {
				writeByte((j >> (n -= 8)) & 0xFF);
			}
		}
		position = 0;
	}
}