Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

noah aronsson-brown www.deafmetal.com

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

memoization

// description of your code here

package
{
	public class Memo
	{
		static public function Memoize(obj:*, func:Function):Function
		{
			// *** Each argument to func must provide a unique value when
			// *** converted to a string. For example, something that just
			// *** prints out as [Object] will not work.
			
			var hash:Object = {};
			var f:Function = function(...args):*
			{
			// Check hash for result.
			
				var key:String = args.join(",");
				var result:* = hash[key];
				
				if (result == null)
				{
					result = func.apply(obj, args);
					hash[key] = result;
				}
				
				return result;
			
			}
			
			return f;
		}
	}
}

sys font alpha in as3

// apply a filter to a system font in order to adjust alpha

myTextField.filters = [new BlurFilter(0,0,0)];
myTextField.alpha = 0.5;
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS