Adobe
Products
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
Student and Teacher Editions
More products
Solutions
Creative tools for business
Digital marketing
Digital media
Education
Financial services
Government
Web Experience Management
More solutions
Learning Help Downloads Company
Buy
Home use for personal and home office
Education for students, educators, and staff
Business for small and medium businesses
Licensing programs for businesses, schools, and government
Special offers
Search
 
Info Sign in
Welcome,
My cart
My orders My Adobe
My Adobe
My orders
My information
My preferences
My products and services
Sign out
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out My orders My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Review and Checkout
Adobe Developer Connection / Pixel Bender Technology Center /

Effects with the Pixel Bender Toolkit – Part 10: Using a multiple-input filter as a blend shader

by Kevin Goldsmith

Kevin Goldsmith

Content

  • Setting up the files
  • Creating a new Flash file
  • Adding the code the integrate the multiple-input filter
  • Where to go from here

Modified

11 January 2010

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
Flash Professional graphic effects Pixel Bender

Requirements

Prerequisite knowledge

Some familiarity with ActionScript 3.

User level

Beginning

Required products

  • Flash Player 10 and later
  • Flash Professional (Download trial)
  • Pixel Bender Toolkit (Macintosh)
  • Pixel Bender Toolkit (Windows)

Sample files

  • pixel_bender_10.zip (5896 KB)

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.

Setting up the files

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.

Creating a new Flash file

To begin, create a brand new Flash file and set it up for this project. Follow these steps:

  1. Launch Flash CS4.
  2. Choose File > New and select the option to create a new Flash File (ActionScript 3.0).
  3. Select the blank keyframe on Frame 1 of Layer 1.
  4. Choose File > Import > Import to Stage. In the dialog box that appears, browse to select the ShrineNearDarjeeling.png file.

    Note: Use the platform specific path below to locate the image on your machine:

    • Windows: C:\Program Files (x86)\Adobe\Adobe Utilities\Pixel Bender Toolkit\sample images
    • Mac OS: Mac HD/Applications/Utilities/Adobe Utilities/Pixel Bender Toolkit/sample images
  5. Select the ShrineNearDarjeeling.png image located in the sample images folder and click Import.
  6. Click the gray area outside the Stage. Use the Property inspector to edit the size of the Stage. After clicking Edit, choose the option to Match Contents. Click OK.
  7. Choose File > Import > Import to Stage. In the dialog box that appears, browse to select the YellowFlowers.png file in the sample images folder. Click Import. Use the same path shown above, depending on your operating system, to access the sample images folder. Now both of the images are imported onto the Stage on same layer.
  8. While the yellow flower image is still selected, press the Q key to access the Free Transform tool. Resize the flower image to match the dimensions of the ShrineNearDarjeeling image. Position the flower image so that it completely covers the image underneath.
  9. Right-click (or Control-click) the flower image and select the Convert to Symbol option.
  10. In the Convert to Symbol dialog box, enter the name the new symbol: flower_mc. Use the Type menu to select Movie Clip. Click OK.
  11. In the Property inspector, enter the instance name of the flower image: flower. If you've been following these instructions from the beginning, you'll remember that this is the same process described in Part 5 of this series.
  12. Choose File > Save and save the Flash file. Name it Exercise10.fla and save it in the folder named pixel_bender on your desktop.

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.

Adding the code the integrate the multiple-input filter

In this section, you'll add the ActionScript to link the filter you created in Part 9 to the Flash project. Follow these steps:

  1. Choose Window > Actions to open the Actions panel.
  2. Create a new layer above the current layer and name it AS. Select Frame 1 of the AS layer.
  3. Enter the following code into the Script window to load the Pixel Bender filter:
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.

  1. Choose Debug > Debug Movie. If you do not encounter any syntax errors, Flash Player launches and shows the two images as cross-faded (see Figure 1).
  2. Choose File > Save to save the Flash Project and save your changes.
Blended images displayed in Flash Player 10
Figure 1. Blended images displayed in Flash Player 10

Where to go from here

Check out the following resources to learn more about working with the Pixel Bender Toolkit:

  • Pixel Bender forum
  • Pixel Bender basics for Flash
  • Pixel Bender basics for Flex and AIR
  • Pixel Bender basics for Flex and AIR

Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License+Adobe Commercial Rights

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.

More Like This

  • Pixel Bender release notes
  • Effects with the Pixel Bender Toolkit – Part 1: Creating a new filter
  • Effects with the Pixel Bender Toolkit – Part 2: Creating a vintage tone filter
  • Effects with the Pixel Bender Toolkit – Part 3: Adding parameters to filters
  • Effects with the Pixel Bender Toolkit – Part 4: Sampling multiple pixels
  • Effects with the Pixel Bender Toolkit – Part 5: Applying a filter to an image in Flash
  • Effects with the Pixel Bender Toolkit – Part 6: Modifying Pixel Bender parameters in Flash
  • Effects with the Pixel Bender Toolkit – Part 7: Improving the displacement filter
  • Effects with the Pixel Bender Toolkit – Part 8: Controlling the displacement filter with mouse positioning
  • Effects with the Pixel Bender Toolkit – Part 9: Integrating multiple image sources with a Pixel Bender kernel

Tutorials & Samples

Tutorials

  • Animating a particle system
  • Improving the displacement filter in Pixel Bender
  • Controlling the displacement filter in Pixel Bender with mouse positioning

Samples

Pixel Bender Forum

More
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

Pixel Bender Exchange

More
Escher's Droste Effect
4D Quaternion Julia-set Ray Tracer with Ambient Occlusion
Raytracer
Zoom Blur Focus

Products

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • Mobile Apps
  • Photoshop
  • Touch Apps
  • Student and Teacher Editions

Solutions

  • Digital marketing
  • Digital media
  • Web Experience Management

Industries

  • Education
  • Financial services
  • Government

Help

  • Product help centers
  • Orders and returns
  • Downloading and installing
  • My Adobe

Learning

  • Adobe Developer Connection
  • Adobe TV
  • Training and certification
  • Forums
  • Design Center

Ways to buy

  • For personal and home office
  • For students, educators, and staff
  • For small and medium businesses
  • For businesses, schools, and government
  • Special offers

Downloads

  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2012 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy Policy and Cookies (Updated)

Ad Choices

Reviewed by TRUSTe: site privacy statement