KM 8.1 Chroma key filter [AS3, FP10]
KM 8.1 has a new filter you can use for chroma keying.
KeyFilter(keyColor, chromaTolerance, lumaTolerance, toleranceRange, preBlur, invertMask)
keyColor is a color value
chromaTolerance, lumaTolerance and toleranceRange are numbers from 0.0 to 1.0
preBlur and invertMask are boolean values
The filter works just like other filters.
You can use it from the gui or from ActionScript.
An actionscript example :
code:
import km.filters.*;
var f:KeyFilter = new KeyFilter(0x00ff00, 0.4, 1.0);
mc1.filters = [f];
The filter compares the chroma and luma components of the key color you supply with the chroma and luma components of each pixel of the object the filter is applied to and makes the pixel transparent if the differences between the components are within the specified tolerances.
If you specify a toleranceRange of 0 (or omit it), the pixels become either transparent or stay the same. If you specify a bigger value, the transparency will change gradually within the specified range.
With the preBlur parameter set to true, the filter slightly blurs the object before the chroma and luma components are compared. The result will not be blurred but the edges will become a little softer.
Most of the times setting it to true looks best but it does result in a higher cpu load compared to setting it to false.