Return to Snippet

Revision: 25728
at April 7, 2010 04:46 by adrianparr


Initial Code
// import flash.filters.ColorMatrixFilter;

function blackAndWhite($target:DisplayObject, $enabled:Boolean):void
{
	var rc:Number = 1/3;
	var gc:Number = 1/3;
	var bc:Number = 1/3;
	var cmf:ColorMatrixFilter = new ColorMatrixFilter([rc, gc, bc, 0, 0, rc, gc, bc, 0, 0, rc, gc, bc, 0, 0, 0, 0, 0, 1, 0]);

	if ($enabled) {
		$target.filters = [cmf];
	} else {
		$target.filters = [];
	}
}

blackAndWhite(myMovieClip, true);

Initial URL
http://chargedweb.com/labs/2010/03/18/fast-blacknwhite-trick/

Initial Description
This handy little function can be used to convert a displayObject to black and white.

Initial Title
AS3 Convert DisplayObject to Black and White

Initial Tags
color

Initial Language
ActionScript 3