11 January 2010
Some familiarity with ActionScript 3.
Beginning
In this article, you'll learn how to bring a multiple-image-manipulating filter from the Pixel Bender Toolkit to work in a Flash CS4 project. This is the tenth, and final, installment in this series of articles about using the Pixel Bender Toolkit to create visual effects with bitmap images.
In the previous section, you learned how to create a Pixel Bender kernel that integrates values from multiple image sources. You blended two images together and also learned how to control the way the effect blends the images by adjusting the filter's parameters.
In this final installment, you'll take the filter you created in Part 9, create a new Flash CS4 project, and then add the ActionScript code to display the effect in Flash Player 10.
If you completed Part 9, you can work with the filter that you already created, named Exercise9Filter.pbk, and apply it as a blend mode within Flash. If you are just beginning to follow along with these instructions, download the sample files provided, uncompress the ZIP file, and save the contents into a folder called pixel_bender on your desktop.
To begin, create a brand new Flash file and set it up for this project. Follow these steps:
Note: Use the platform specific path below to locate the image on your machine:
In the next section, you'll learn how to add the ActionScript to make the filter run on the two imported images in Flash Player 10.
In this section, you'll add the ActionScript to link the filter you created in Part 9 to the Flash project. Follow these steps:
var urlRequest:URLRequest = new URLRequest("Exercise9Filter.pbj");
var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.addEventListener( Event.COMPLETE, applyFilter );
urlLoader.load(urlRequest);
var shader:Shader;
function applyFilter( event:Event ):void
{
urlLoader.removeEventListener( Event.COMPLETE, applyFilter );
shader = new Shader( event.target.data );
shader.data.amount.value = [0.5];
flower.blendShader = shader;
}
Note: If you've been following along with this article series since the beginning, you'll notice that this code is very similar to the filter-loading code you wrote in Part 5.
Check out the following resources to learn more about working with the Pixel Bender Toolkit:
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.
Tutorials & Samples |
| 04/10/2012 | Fast Fourier Transform (FFT) in Pixel Bender? |
|---|---|
| 04/19/2012 | Shader works in toolkit, not in Flash |
| 04/12/2012 | Pixel Bender removed from AE CS6 !? |
| 03/22/2012 | Load an HDR image into Pixel Bender Toolkit |