The gist of it is that I've added three functions and one new field to FlxSprite.

As a user, you use setFilter() and removeFilter(). You pass either a BitmapFilter or an Array of BitmapFilters to setFilter.

Then, you add applyFilter(filter) to the bottom of calcFrame(), so that it applies the filters after generating the bitmap for the sprite. There's one little bug right now where filters that expand the size of the input bitmap will get that extra data truncated off, but besides that, it works great so far.

` protected var filter:*;`

public function setFilter(filter:*):void

{

if(filter != null && this.filter == filter)

{

return;

}

this.filter = filter;

calcFrame();

}

public function removeFilter(filter:*):void

{

if(this.filter == null || filter == null)

{

return;

}

if(this.filter is Array)

{

//Replace with your own Array.remove function.

ArrayUtil.removeValueFromArray(this.filter as Array, filter);

calcFrame();

}

else if(this.filter != null && this.filter == filter)

{

this.filter = null;

calcFrame();

}

}

protected function applyFilter(filter:*):void

{

if(filter != null)

{

_flashRect.x = _flashRect.y = 0;

_flashRect.width = _framePixels.width;

_flashRect.height = _framePixels.height;

_flashPointZero.x = 0;

_flashPointZero.y = 0;

if(filter is Array)

{

for each(var o:Object in filter)

{

applyFilter(o);

}

}

else if(filter is BitmapFilter)

{

_framePixels.applyFilter(_framePixels, _flashRect, _flashPointZero, filter as BitmapFilter);

}

}

}

Besides that, the rest is actually figuring out how to use the filter classes. ColorMatrixFilter is a little tricky, so I've provided my default implementations for some of the effects I was able to pull off.

` public static function createGrayscaleFilter():ColorMatrixFilter`

{

var matrix:Array = new Array();

matrix = matrix.concat([0.5,0.5,0.5,0,0]);

matrix = matrix.concat([0.5,0.5,0.5,0,0]);

matrix = matrix.concat([0.5,0.5,0.5,0,0]);

matrix = matrix.concat([0,0,0,1,0]);

return new ColorMatrixFilter(matrix);

}

public static function createSepiaFilter():ColorMatrixFilter

{

var matrix:Array = new Array();

matrix = matrix.concat([0.34, 0.33, 0.33, 0.00, 30.00]);

matrix = matrix.concat([0.33, 0.34, 0.33, 0.00, 20.00]);

matrix = matrix.concat([0.33, 0.33, 0.34, 0.00, 0.00]);

matrix = matrix.concat([0.00, 0.00, 0.00, 1.00, 0.00]);

return new ColorMatrixFilter(matrix);

}

public static function createNegativeFilter():ColorMatrixFilter

{

var matrix:Array = new Array();

matrix = matrix.concat([-1, 0, 0, 0, 255]);

matrix = matrix.concat([0, -1, 0, 0, 255]);

matrix = matrix.concat([0, 0, -1, 0, 255]);

matrix = matrix.concat([0, 0, 0, 1, 0]);

return new ColorMatrixFilter(matrix);

}

Doing the color overlay (tint) and HSB was yet trickier, and I ended up using a 3rd party library to do that for me (look up Quasimondo's ColorMatrix).

Does anybody know if it would be possible to replicate something akin to Photoshop's "stroke" effect? Or a reflection effect? There probably are implementations of these, but I don't think I've seen them done in a BitmapFilter compatible form.