In this chapter I'll discuss how to apply filters to your viewport, in turn, applying the filter across all objects in your scene. For this example I'll use a PV3D generated Sphere and apply the various filters to the viewport.
Drop Shadow Filter
example: Drop Shadow Filter
source: Drop Shadow Filter Source
This is the code for inserting a drop shadow filter on your viewport. The first thing you need to do is import the flash filters API. For simplicity purposes I'm going to import all filters. You can do that by using * at the end of the flash.filters.* directory.
//import filters api
import flash.filters.*;
//datatype your filter variable
public var dropShadowFilter:DropShadowFilter;
//instantiate your dropShadowFilter var with its parameters
//dropShadowFilter = new DropShadowFilter(distance, angle, color, alpha, x blur, y blur,
//strength, quality, inner shadow boolean, knockout boolean, hide object boolean);
dropShadowFilter = new DropShadowFilter(5, 45, 0x000000, 1, 5, 5, 1, 1);
//apply your filter to the viewport
//viewport.filters = [filter1 to apply, filter2 to apply];
viewport.filters = [dropShadowFilter];
Preview the fla and you'll see your filter in action.
Blur Filter
example: Blur Filter
source: Blur Filter Source
This is the code for inserting a blur filter on your viewport.
//import filters api
import flash.filters.*;
//datatype your filter variable
public var blurFilter:BlurFilter;
//instantiate your blurFilter var with its parameters
//blurFilter = new BlurFilter(x blur, y blur, quality);
blurFilter = new BlurFilter(10, 10, 1);
//apply your filter to the viewport
//viewport.filters = [filter1 to apply, filter2 to apply];
viewport.filters = [blurFilter ];
Preview the fla and you'll see your filter in action.
Glow Filter
example: Glow Filter
source: Glow Filter Source
This is the code for inserting a glow filter on your viewport.
//import filters api
import flash.filters.*;
//datatype your filter variable
public var glowFilter:GlowFilter;
//instantiate your glowFilter var with its parameters
//glowFilter = new GlowFilter(color, alpha, x blur, y blur,
//strength, quality, inner glow bloolean, knockout boolean);
glowFilter = new GlowFilter(0xFF0000, 1, 10, 10, 2, 1);
//apply your filter to the viewport
//viewport.filters = [filter1 to apply, filter2 to apply];
viewport.filters = [glowFilter];
Preview the fla and you'll see your filter in action.
Bevel Filter
example: Bevel Filter
source: Bevel Filter Source
This is the code for inserting a bevel filter on your viewport.
//import filters api
import flash.filters.*;
//datatype your filter variable
public var bevelFilter:BevelFilter;
//instantiate your bevelFilter var with its parameters
//bevelFilter = new BevelFilter(distance, angle, highlight color, highlight alpha,
//shadow color, shadow alpha, x blur, y blur, strength, quality,
//bevel type string, knockout boolean);
bevelFilter = new BevelFilter(8, 45, 0xAAAAAA, 1, 0x000000, 1, 4, 4, 1, 1, "inner");
//apply your filter to the viewport
//viewport.filters = [filter1 to apply, filter2 to apply];
viewport.filters = [bevelFilter];
Preview the fla and you'll see your filter in action.
skip to main |
skip to sidebar
Jim Foley's Brain. Flex, Flash, Papervision 3D, Swift 3D and other cool stuff.
Back on top ^
created by Nuvio | Webdesign
MAD VERTICES © 2008 Ken ahlin | Converted to XML Blogger Template by ThemeLib
Thanks Jim!
The blur and shadow effects are great!
This is great. I did not think about applying a filter to the viewport. If there a way I can only apply the filter, say a dropshadow, to one specific element on the stage?
For example, I have five planes on my stage, I only want one to have a filter applied. Would I need a new viewport for each plane?
Forgive me if I sound ignorant - I am, and I'm trying to learn!!
Much thanks.
Bryan
Hey Bryan,
You'd have to use the effects branch for that type of filtering. I haven't tried it yet myself but it is possible.
Gday, how do you go about applying a filter to a cube that needs to be continually rendered as it is reacting to mouse.X and mouse.Y?
This effects are apply only to viewport...but if i want apply dnly at the boject sphere? not to all abject in viewport?
It's possible to apply filter only to one specific DisplayObject3d,use
DisplayObject.useOwnContainter=true;
DisplayObject.filters[yourFilterHere];
@All - If you're looking to apply filters to objects within the scene see this post: http://blog.zupko.info/?p=129