Goals
Ok, let's resume our task:
- Capture images from a video
- Show this screenshots, applying different filters (DropShadowFilter, BlurFilter and ColorMatrixFilter)
- Pass the source screenshot (without the filter) to a PHP file that converts
to a jpg image
With the new BitmapData class this is not a difficult task at all. We begin importing necessary classes
import flash.display.BitmapData;
import flash.filters.DropShadowFilter
import flash.filters.BlurFilter;
import flash.geom.Matrix;
import flash.filters.ColorMatrixFilter;
Filters
After that, we need to build each of the filters. Help on this version is much better documented. So can see Flash Help to understand how to use each of the filters. The first one is the ColorMatrixFilter. 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, basically used for saturation changes, hue rotation, luminance to alpha and various other effects. This filter use a Matrix to shift each channel (RGB) plus the alpha channel. Here we just saturate the color but you can play with the matrix to get different results
//Build color Matrix Filter<br>
var matrix:Array = new Array();<br>
matrix = matrix.concat([1, 0, 0, 1, 0]); // red<br>
matrix = matrix.concat([0, 1, 0, 0, 0]); // green<br>
matrix = matrix.concat([0, 0, 1, 1, 0]); // blue<br>
matrix = matrix.concat([0, 0, 0, 1, 0]); // alpha<br>
var filterCol:ColorMatrixFilter = new ColorMatrixFilter(matrix);

The DropShadowFilter is more easy. You pass an offset, color and degree for the shadow in the constructor (see docs for each parameter). Here's our filter:
var shadowFilter:DropShadowFilter = new DropShadowFilter(5, 45, 0x000000, 100, 20, 20, 2, 2, false, false, false)
Finally the Blur Filter (blur amount in both axis and quality, see docs) and the array of filters ready to apply to some MovieClip. Note that the filters determine mathematical operations over a source, even if the source is not defined yet. This rules will be applied to any target, and we will do in a while.
//Build BlurFilter<br>
var blur:BlurFilter = new BlurFilter(10, 10, 2);<br>
//Array of filters<br>
myFilters = new Array(shadowFilter, blur, filterCol)

5 most recent
Flash button as Flex icon
Tree menu
Flash Spell Checker
Flash Remoting Library
MX 2004 Chart/Poll
Articles