Using Pixel Bender Filters within Flex
Following up on my earlier post on how to embed Pixel Bender filters within a SWF, here is a super simple example that show how to use a Pixel Bender filter within a Flex application.
Compiled using the Flex 3.1.0.2710 SDK, and requires Flash Player 10.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
applicationComplete="onApplicationComplete()">
<mx:Script>
<![CDATA[
import flash.filters.*;
import flash.utils.ByteArray;
//the file that contains the binary bytes of the PixelBender filter
[Embed("testfilter.pbj", mimeType="application/octet-stream")]
private var TestFilter:Class;
private function onApplicationComplete():void
{
//Pass the loaded filter to the Shader as a ByteArray
var shader:Shader = new Shader(new TestFilter() as ByteArray);
shader.data.amount.value = [100];
var filter:ShaderFilter = new ShaderFilter(shader);
//add the filter to the image
im.filters = [filter];
}
]]>
</mx:Script>
<mx:Image right="288" left="40" top="26" bottom="108" id="im" source="@Embed(source='image.jpg')"/>
</mx:Application>
You can see an example of the filter here.
You can find more information on Pixel Bender here.
You can download the filter from here.






[...] Using Pixel Bender Filters within Flex [...]
localToGlobal » Blog Archive » news review -> 37th week of 2008
12 Sep 08 at 2:20 am
Great read mike!
But can we change shader filter values on the fly?
I tried binding the amount.value to a HSlider but it doesn’t appear to work.
Hyder Alamgir
19 Apr 09 at 10:12 am
[...] lets look at how you would normally apply a PxB shader. The following example is taken from Mike Chamber’s blog: import flash.filters.*; import flash.utils.ByteArray; //the file that contains the binary [...]
Using Pixel Bender to Process Lots of Data « blog
24 Mar 10 at 4:39 pm