You need to define your matrix array
before you instantiate the ColorMatrixFilter
object. Also, ColorMatrixFilter
expects a one dimensional array
. See documentation which recommends a syntax using concat
which seems to do the trick.
Try updating your code with the following:
// Matrix should be a one dimensional array
var colorMatrix:Array = new Array();
colorMatrix = colorMatrix.concat([0, 0, 1, 0, 0]),
colorMatrix = colorMatrix.concat([0, 1, 0, 0, 0]),
colorMatrix = colorMatrix.concat([1, 0, 0, 0, 0]),
colorMatrix = colorMatrix.concat([0, 0, 0, 1, 0]);
// Matrix needs to be defined before it's added to the ColorMatrixFilter
var colorFilter:ColorMatrixFilter = new ColorMatrixFilter(colorMatrix);