Skip to content

Instantly share code, notes, and snippets.

@alexkojin
Created January 6, 2010 19:23
Show Gist options
  • Save alexkojin/270548 to your computer and use it in GitHub Desktop.
Save alexkojin/270548 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" creationComplete="preinit(event)" layout="vertical" width="100%" height="100%">
<fx:Script>
<![CDATA[
import flash.filters.ShaderFilter;
[Embed(source="assets/verticalGaussianBlur.pbj", mimeType="application/octet-stream")]
private var MedianSimple:Class;
var bitmapData:BitmapData;
private function preinit(e:Event):void{
bitmapData= new BitmapData(img.width, img.height, true);
bitmapData.draw(img);
init(e);
}
private function init(e:Event):void{
var shader:Shader = new Shader(new MedianSimple());
shader.data.src.input = bitmapData;
shader.data.strength.value = [amountSlider.value];
var res:BitmapData = new BitmapData(img.width, img.height);
var job:ShaderJob = new ShaderJob(shader);
job.target = res;
job.start(true);
img.addChild(new Bitmap(res));
}
]]>
</fx:Script>
<mx:HBox>
<mx:Grid>
<mx:GridRow>
<mx:GridItem>
<mx:HBox>
<mx:Label text="Strength" />
<mx:HSlider id="amountSlider" minimum="0.0" maximum="1.0" labels="['0', '100%']" value=".5" liveDragging="true" change="init(event)" />
</mx:HBox>
</mx:GridItem>
<mx:GridItem>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow>
<mx:GridItem>
<mx:VBox>
<mx:Label text="Blurry" />
<mx:Image id="img" source="@Embed('assets/cat.jpg')" height="375" width="500" />
</mx:VBox>
</mx:GridItem>
</mx:GridRow>
</mx:Grid>
</mx:HBox>
</mx:Module>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment