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: Testing Dictionary Class

Get Adobe Flash player
by Fumio 24 Feb 2010
/**
 * Copyright Fumio ( http://wonderfl.net/user/Fumio )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/5fxo
 */

// forked from Fumio's Testing Dictionary Class
package {
	import flash.display.Sprite;
	import flash.display.Graphics;
	import flash.utils.Dictionary;
	import flash.geom.Point;
	import flash.filters.*;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	public class DictionaryTest extends Sprite {
		private var nColor:uint = 0xFF00FF;
		private var sizePoint:Point = new Point(100,25);
		private var myDictionary:Dictionary = new Dictionary();
		public function DictionaryTest() {
			var mySprite:Sprite;
			mySprite = createSprite(10,10);
			myDictionary[mySprite] = new BevelFilter();
			mySprite = createSprite(10,50);
			myDictionary[mySprite] = new BlurFilter();
			mySprite = createSprite(10,90);
			myDictionary[mySprite] = new GlowFilter();
			//
			addComment();
		}
		private function createSprite(nX:Number, nY:Number):Sprite {
			var mySprite:Sprite = new Sprite();
			var myGraphics:Graphics = mySprite.graphics;
			addChild(mySprite);
			mySprite.addEventListener(MouseEvent.CLICK, applyFilter);
			myGraphics.beginFill(nColor);
			myGraphics.drawRect(0, 0, sizePoint.x, sizePoint.y);
			mySprite.x = nX;
			mySprite.y = nY;
			return mySprite;
		}
		private function applyFilter(eventObject:MouseEvent):void {
			var mySprite:Sprite = eventObject.currentTarget as Sprite;
			mySprite.filters = [myDictionary[mySprite]];
			mySprite.removeEventListener(MouseEvent.CLICK, applyFilter);
		}
		private function addComment():void {
			var _txt:TextField = new TextField();
			addChild(_txt);
			_txt.autoSize = TextFieldAutoSize.LEFT;
			_txt.text = "<- click any rectangle";
			_txt.x = 120;
			_txt.y = 55;
		}
	}
}