Here is where the fun really begins. We can very easily apply a pixel Bender filter to a BitmapData which will alter all pixels in it or we can also use a Pixel bender filter as a filter like you would use any other Flash built-in filter. Let's see this in action, I added a BitmapData in the library and loaded a different filter:

var shader:Shader;   
var bitmap:Bitmap = new Bitmap(new Autumn(0,0));
addChild(bitmap);
function onLoadComplete(event:Event):void {
shader = new Shader(loader.data);
stage.addEventListener(MouseEvent.CLICK, addBender);
}
function addBender(e:MouseEvent):void{
shader.data.src.input = new Autumn(0,0);//set the input
var shaderjob:ShaderJob = new ShaderJob(shader, bitmap.bitmapData);//apply the filter on the bitmapdata of our bitmap
shaderjob.start();
}

And here is the result, click once to apply the filter:



This alters directly the BitmapData pixels. Another way is to create a ShaderFilter which you can then apply to any DisplayObject:

var shaderfilter:ShaderFilter;
function onLoadComplete(event:Event):void {
shader = new Shader(loader.data);
shaderfilter = new ShaderFilter(shader)
stage.addEventListener(MouseEvent.CLICK, addBender);
}
function addBender(e:MouseEvent):void{
bitmap.filters = [shaderfilter];
}

Here is the result:


Now that's not a lot of code. We could now tween properties using either tweens or timer or enterframe events and get quite impressive results. I'll leave that for you to experiment and come out with your own solutions. But to get to the point I wrote a little class (see zip file) that does just that so let's try on some filters here:









The code for all this is quite simple and it's about the same for all these examples, only the property being animated changes. You can just download all the files and play with all this. Just remember that the property must match the property defined in the Pixel Bender.

import ASWC.*;

var shader:ShaderExtended = new ShaderExtended("cone.pbj");
shader.addEventListener(ShaderExtended.SHADER_READY, get_filter);
var bitmap:Bitmap = new Bitmap(new Tree(0,0));
addChild(bitmap);
function get_filter(e:Event):void{
stage.addEventListener(MouseEvent.CLICK, addBender);
}
function addBender(e:MouseEvent):void{
shader.setInput({src:new Tree(0,0)});
shader.animate(30, null, { offset:[10,0]}, bitmap.bitmapData, false);
}

That's all for this introduction to Pixel Bender and Shader. Contact me if you have any questions and don't hesitate to leave a comment!