Fast black’n'white trick



1 Comment

Share




Sometimes i need a fast black’n'white saturation method and this one’s the shortest i presume.
I can’t remember whose this method originally was, but it’s nice.


private var rc:Number = 1/3, gc:Number = 1/3, bc:Number = 1/3;
private var sf:ColorMatrixFilter = new ColorMatrixFilter([rc, gc, bc, 0, 0, rc, gc, bc, 0, 0, rc, gc, bc, 0, 0, 0, 0, 0, 1, 0]);
				
private function blackAndWhite(target:UIComponent, enabled:Boolean):void
{
   if(enabled) target.filters = [sf];
   else target.filters = [];
}