User Guide

ColorMatrixFilter (flash.filters.ColorMatrixFilter) 423
See also
Object
ColorMatrixFilter
(flash.filters.ColorMatrixFilter)
Object
|
+-flash.filters.BitmapFilter
|
+-flash.filters.ColorMatrixFilter
public class ColorMatrixFilter
extends BitmapFilter
The ColorMatrixFilter class lets you apply a 4 x 5 matrix transformation on the RGBA color
and alpha values of every pixel on the input image to produce a result with a new set of RGBA
color and alpha values. It allows saturation changes, hue rotation, luminance to alpha and
various other effects. You can apply this filter to bitmaps and MovieClip instances.
The use of filters depends on the object to which you apply the filter:
To apply filters to movie clips at runtime, use the filters property. Setting the filters
property of an object does not modify the object and can be undone by clearing the
filters property.
To a pp ly f ilt ers to Bit map Data instances, use the BitmapData.applyFilter() method.
Calling
applyFilter() on a BitmapData object takes the source BitmapData object and
the filter object and generates a filtered image as a result.
You can also apply filter effects to images and video at authoring time. For more information,
see your authoring documentation.
If you apply a filter to a movie clip or button, the
cacheAsBitmap property of the movie clip
or button is set to
true. If you clear all filters, the original value of cacheAsBitmap is
restored.
The following formulas are used, where a[0] through a[19] correspond to entries 0 through
19 in the 20-element array property matrix:
redResult = a[0] * srcR + a[1] * srcG + a[2] * srcB + a[3] * srcA + a[4]
greenResult = a[5] * srcR + a[6] * srcG + a[7] * srcB + a[8] * srcA + a[9]
blueResult = a[10] * srcR + a[11] * srcG + a[12] * srcB + a[13] * srcA +
a[14]
alphaResult = a[15] * srcR + a[16] * srcG + a[17] * srcB + a[18] * srcA +
a[19]