/ Published in: ActionScript 3
This handy little function can be used to convert a displayObject to black and white.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// 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);
URL: http://chargedweb.com/labs/2010/03/18/fast-blacknwhite-trick/