Adobe
Products

Top destinations

  • Adobe Creative Cloud
  • Creative Suite 6
  • Adobe Marketing Cloud
  • Acrobat
  • Photoshop
  • SiteCatalyst
  • Students
  • Elements family

Adobe Creative Cloud

  • What is Adobe Creative Cloud?
  • Design
  • Web
  • Photography
  • Video
  • Students
  • Teams
  • Enterprise
  • Educational institutions
  • Government

Design and photography

  • Photoshop
  • Illustrator
  • InDesign
  • Adobe Muse
  • Lightroom

Video

  • Adobe Premiere
  • After Effects

Web development and HTML5

  • Edge Tools & Services [opens in a new window]
  • Dreamweaver
  • Gaming [opens in a new window]

Adobe Marketing Cloud

  • What is Adobe Marketing Cloud?
  • Digital analytics
  • Social marketing
  • Web experience management
  • Testing and targeting
  • Media optimization

Analytics

  • SiteCatalyst
  • Adobe Discover
  • Insight

Social

  • Adobe Social

Experience Manager

  • CQ
  • Scene7

Target

  • Test&Target
  • Recommendations
  • Search&Promote

Media Optimizer

  • AdLens
  • AudienceManager
  • AudienceResearch

Document services

  • Acrobat
  • EchoSign [opens in a new window]
  • FormsCentral [opens in a new window]
  • SendNow [opens in a new window]
  • Acrobat.com [opens in a new window]

Publishing

  • Digital Publishing Suite

  • See all products
Business solutions

By business need

  • Digital analytics
  • Digital publishing
  • Document management
  • Media optimization
  • Social marketing
  • Testing and targeting
  • Video editing and serving
  • Web development [opens in a new window]
  • Web experience management
  • See all business needs

By industry

  • Broadcast
  • Education
  • Financial services
  • Government
  • Publishing
  • Retail
  • See all industries
Support & Learning

I need help

  • Products
  • Adobe Creative Cloud
  • Adobe Marketing Cloud
  • Forums [opens in a new window]

I want to learn

  • Training and tutorials
  • Certification [opens in a new window]
  • Adobe Developer Connection
  • Adobe Design Center
  • Adobe TV [opens in a new window]
  • Adobe Marketing Center
  • Adobe Labs [opens in a new window]
Download
  • Product trials
  • Adobe Flash Player
  • Adobe Reader
  • Adobe AIR
  • See all downloads
Company
  • Careers at Adobe
  • Investor Relations
  • Newsroom
  • Privacy
  • Corporate Social Responsibility
  • Customer Showcase
  • Contact us
  • More company info
Buy
  • For personal and professional use
  • For students, educators, and staff
  • For small and medium businesses
  • Volume Licensing
  • Special offers
  • Adobe Marketing Cloud sales [opens in a new window]
Search
 
Info Sign in
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Welcome,
My Adobe
My orders
My information
My preferences
My products and services
Sign out
My cart
Privacy My Adobe
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out Privacy 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
Promotions
Estimated shipping
Tax
Calculated at checkout
Total
Review and Checkout
Adobe Developer Connection / Pixel Bender Technology Center /

Effects with the Pixel Bender Toolkit – Part 5: Applying a filter to an image in Flash

by Kevin Goldsmith

Kevin Goldsmith

Content

  • Setting up the files
  • Loading the Pixel Bender bytecode file into Flash
  • Applying the Pixel Bender filter on the image
  • Where to go from here

Created

11 January 2010

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
Flash Professional CCgraphic effectsPixel Bender
Was this helpful?
Yes   No

By clicking Submit, you accept the Adobe Terms of Use.

 
Thanks for your feedback.

Requirements

Prerequisite knowledge

Some familiarity with ActionScript 3.

User level

Beginning

Required products

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

Sample files

  • pixel_bender_05.zip (1535 KB)

In this article, you'll apply a Pixel Bender filter that you saved in Part 2 in this series to an image in Adobe Flash Professional CS4. This is the fifth 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 sample multiple pixels from the same image to create an offset effect. You also added code to reduce the saturation and display the image without doubling the values of the pixels.

In this section, you'll learn how to apply a filter to an image that appears in Flash Player. You'll use the Shader and the ShaderFilter classes to create a vintage tone effect.

Setting up the files

If you are jumping into this article series at this point and didn't complete Part 2, download the sample files provided. You'll use the file named Exercise2Filter.pbj as the filter for this section.

Follow these steps:

  1. Launch Flash CS4 Professional.
  2. Choose File > New and select the option to create a new Flash File (ActionScript 3.0).
  3. Choose File > Import > Import to Stage. Browse to select the YellowFlowers.jpg image that exists at the following location, depending on your operating system:
    • 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
  4. Click the YellowFlowers.png file and then click Import. The flower image appears on the Stage (see Figure 1).
  5. Choose File > Save. In the dialog box that appears, rename the untitled file as Exercise5.fla. Save the file in the pixel_bender folder on your desktop.
Imported yellow flower image displayed on the Stage in Flash CS4
Figure 1. Imported yellow flower image displayed on the Stage in Flash CS4

Loading the Pixel Bender bytecode file into Flash

Now that you've set up a Flash project file (FLA file) with an imported bitmap image, the next task is to link the Pixel Bender code that you created previously. The code that you link will create a sepia effect on the flower image.

Follow these steps:

  1. Choose Window > Actions to open the Actions panel, if it is not already open.
  2. Select Frame 1 in the Flash Timeline.
  3. In the Script window of the Actions panel, enter the following code:
var urlRequest:URLRequest = new URLRequest("Exercise2Filter.pbj"); var urlLoader:URLLoader = new URLLoader(); urlLoader.dataFormat = URLLoaderDataFormat.BINARY; urlLoader.addEventListener( Event.COMPLETE, applyFilter ); urlLoader.load(urlRequest); function applyFilter( event:Event ):void { trace("apply"); }

In the code example shown above, ActionScript loads the filter (Exercise2Filter.pbj) that you created in part two of this series into Flash Player. It also calls a function named applyFilter when the loading operation is complete.

Note: If you did not complete Part 2 of this series, be sure to download the sample files folder and save the files into the same folder where you saved the FLA file to ensure that the path to the Pixel Bender filter is not broken.

  1. Choose Debug > Debug Movie.

If you do not encounter any syntax errors, Flash Player launches to display the Yellow Flowers image. The Output window appears to display the trace command text string: apply (see Figure 2).

If you get an error after launching Flash Player that states that the file could not be found, double-check that both the Exercise5.fla Flash project file (the FLA file) and the Pixel Bender filter named Exercise2Filter.pbj (PBJ file) from Part 2 (or the sample files folder) are saved in the same directory. If one is in a subfolder, the path will be broken.

Output window displaying the string specified in the trace statement command
Figure 2. Output window displaying the string specified in the trace statement command

Applying the Pixel Bender filter on the image

Now that you've added the ActionScript code in the Flash file to link to the Pixel Bender filter, you can begin editing the placeholder code (which is currently a trace statement) to apply an effect.

Follow these steps:

  1. Quit Flash Player. Return to the Flash authoring environment.
  2. Select the yellow flower image on the Stage.
  3. Right-click (control-click) the image and choose the option to Convert to Symbol.
  4. In the Convert to Symbol dialog box, enter the name in the Name field: Flower Image. Use the Type menu to select Movie Clip and click OK (see Figure 3).
Convert to Symbol dialog box
Figure 3. Convert to Symbol dialog box
  1. In the Property inspector, enter the instance name of the image: flower (see Figure 4).
Entering the name in the Instance Name field
Figure 4. Entering the name in the Instance Name field
  1. Choose Window > Actions to open the Actions panel (or click to expand the panel if it is currently collapsed).
  2. Double-check that Frame 1 is selected in the Timeline. You should see the ActionScript code that you wrote in the previous section to load the Pixel Bender filter file.
  3. Locate the following line of code:
trace("apply");
  1. Change the body of the applyFilter ActionScript function, replacing the trace statement with the following code:
urlLoader.removeEventListener( Event.COMPLETE, applyFilter ); var shader:Shader = new Shader( event.target.data ); var shaderFilter:ShaderFilter = new ShaderFilter( shader ); flower.filters = [ shaderFilter ];
  1. Choose Debug > Debug Movie. If you do not encounter syntax errors, Flash Player launches again to show the Yellow Flowers image. This time, the flower displays with a vintage tone effect (see Figure 5).
  2. Save the Flash file in the folder called pixel_bender on your desktop.

See the Flash CS4 Professional ActionScript 3 Language Reference for additional information about working with the Shader and ShaderFilter classes in Flash CS4.

Vintage tone image displayed in Flash Player
Figure 5. Vintage tone image displayed in Flash Player

Where to go from here

After experimenting with sampling multiple pixels from the same image, continue with Part 6 in this series, where you'll learn how to update Pixel Bender parameters in Flash.

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

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

  • Effects with the Pixel Bender Toolkit – Part 10: Using a multiple-input filter as a blend shader
  • Effects with the Pixel Bender Toolkit – Part 8: Controlling the displacement filter with mouse positioning
  • Effects with the Pixel Bender Toolkit – Part 4: Sampling multiple pixels
  • Effects with the Pixel Bender Toolkit – Part 2: Creating a vintage tone filter
  • Pixel Bender release notes
  • Effects with the Pixel Bender Toolkit – Part 3: Adding parameters to filters
  • Effects with the Pixel Bender Toolkit – Part 6: Modifying Pixel Bender parameters in Flash
  • Animating a particle system using Pixel Bender
  • Effects with the Pixel Bender Toolkit – Part 9: Integrating multiple image sources with a Pixel Bender kernel
  • Effects with the Pixel Bender Toolkit – Part 7: Improving the displacement filter

Tutorials & Samples

Tutorials

  • Animating a particle system
  • Using a multiple-input filter in Pixel Bender as a blend shader
  • Controlling the displacement filter in Pixel Bender with mouse positioning

Samples

Pixel Bender Forum

More
05/09/2013 Pixel Bender Installation
02/10/2012 I Cannot get pixel bender to show in PS
05/31/2009 White Hat PBJ Decompiling
01/19/2013 Multiple Image inputs in Blendmode Shader

Pixel Bender Exchange

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

Products

  • Adobe Creative Cloud
  • Creative Suite 6
  • Adobe Marketing Cloud
  • Acrobat
  • Photoshop
  • Digital Publishing Suite
  • Elements family
  • SiteCatalyst
  • For education

Download

  • Product trials
  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR

Support & Learning

  • Product help
  • Forums

Buy

  • For personal and professional use
  • For students, educators, and staff
  • For small and medium businesses
  • Volume Licensing
  • Special offers

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 © 2013 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy (Updated) | Cookies

Ad Choices