Working through in-chapter examples
While you’re working through the chapter, you may want
to test the example code listings that are provided. Because this
chapter deals with creating and manipulating visual content, testing
the code involves running the code and viewing the results in the
SWF that’s created. All the examples create content using the drawing
API which uses or is modified by the shader effect.
Most of the example code listings include two
parts. One part is the Pixel Bender source code for the shader used
in the example. You must first use the Pixel Bender Toolkit to compile
the source code to a Pixel Bender bytecode file. Follow these steps
to create the Pixel Bender bytecode file:
Open Adobe Pixel Bender Toolkit. If necessary, from the
Build menu choose “Turn on Flash Player warnings and errors.”
Copy the Pixel Bender code listing and paste it into the
code editor pane of the Pixel Bender Toolkit.
From the File menu, choose “Export kernel filter for Flash
Player.”
Save the Pixel Bender bytecode file in the same directory
as the Flash document. The file’s name should match the name specified
in the example description.
The ActionScript part of each example is written
as a class file. To test the example:
Create an empty Flash document and
save it to your computer.
Create a new ActionScript file and save it in the same directory
as the Flash document. The file’s name should match the name of
the class in the code listing. For instance, if the code listing
defines a class named MyApplication, use the name MyApplication.as
to save the ActionScript file.
Copy the code listing into the ActionScript file and save
the file.
In the Flash document, click a blank part of the Stage or
work space to activate the document Property inspector.
In the Property inspector, in the Document Class field, enter
the name of the ActionScript class you copied from the text.
Run the program using Control > Test Movie
You will
see the results of the example in the preview window.
These techniques for testing example code listings
are explained in more detail in Testing in-chapter example code listings.