package { import flash.filters.ColorMatrixFilter; [SWF(width=550, height=400, backgroundColor=0xEEEEEE)] /** * Tests application of the ColorMatrixFilter to an image in order to tint it. */ public class graphic_flex_image_effects_02_Flex_ColorMatrixFilterTest extends graphic_flex_image_effects_02_Flex_ImageFilterTest { /** * Applies bitmap filter to image. */ override protected function applyFilter():void { // purple tint to apply var tint:uint = 0xFF00CC; // amount to apply var percent:Number = .5; var r:uint = tint >> 16 & 0xFF; var g:uint = tint >> 8 & 0xFF; var b:uint = tint & 0xFF; var matrix:Array = [ r/255, 0.59, 0.11, 0, 0, g/255, 0.59, 0.11, 0, 0, b/255, 0.59, 0.11, 0, 0, 0, 0, 0, 1, 0 ]; var filter:ColorMatrixFilter = new ColorMatrixFilter(matrix); _bitmap.filters = [filter]; } } }