00:00
00:00
Newgrounds Background Image Theme

Kekiiro just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

AS: Filters 2006-06-11 11:49:52


AS:Main
ONLY FOR FLASH 8+

There have been a long time since I posted a Actionscript tutorial and that's probably because there's not much to write about. But I finnally found a thing to explain.
I know Inglor has made a AS:Filters before but he only included two where one didn't work so here is a bigger list of filters.

If you didn't know already, filters is a way to apply visual effects for text, movieclip and button objects, exclusvie for Flash 8.
You may think that this is hard but some filters are actually really easy to make.
I also have a screenshot of every filter's example in the bottom of the post.
Before you can apply filters through Actionscript you need to import the specific filter from flash.filters.
Now to start explaining every filter (in alphabetic order :) ).
And remember not to only read, copy and paste the code but also try and learn things by experimenting with this filters.

Blur
Syntax: BlurFilter(blurX:Number, blurY:Number, quality:Number);
blurX - The _x blur effect.
blurY - The _y blur effect.
quality - The number of times the filter is applied.
To import use import flash.filters.BlurFilter;
The blur filter is used to blur, soften details, of an image.
Example:
import flash.filters.BlurFilter;
var filter:BlurFilter = new BlurFilter(50, 0, 2);
mc.filters = [filter];

If you make a movieclip called mc this code will blur its _x axe.

Drop Shadow
Syntax: DropShadowFilter(distance:Number, angle:Number, color:Number, alpha:Number, blurX:Number, blurY:Number, strength:Number, quality:Number, inner:Boolean, knockout:Boolean, hideObject:Boolean);
distance - Pixel distance between shadow and object.
angle - The angel of the shadow (0-360), 45 default.
color - The color code (ex: 0x000000 for black).
alpha - The alpha of the shadow (0-100), 100 default.
blurX - The _x blur effect.
blurY - The _y blur effect.
strength - The strength of the shadow.
quality - The number of times the filter is applied.
inner - Indicates if the shadow is on the object or under.
knockout - If true the objects takes the backgrounds color.
hideObject - If true hides the object.
To import use import flash.filters.DropShadowFilter;
The drop shadow filter is used to make objects have shadows, either below or inside.
You can actually skip all the parameters if you want to, but then all parameters are at default state.
Example:
import flash.filters.DropShadowFilter;
var filter:DropShadowFilter = new DropShadowFilter();
mc.filters = [filter];

This code will make a simple drop shadow for the movieclip.

Glow
Syntax: GlowFilter(color:Number, alpha:Number, blurX:Number, blurY:Number, strength:Number, quality:Number, inner:Boolean, knockout:Boolean);
Basicly this is like shadow but isn't using angle since it's around the whole object. If you understand the drop shadow parameters you should understand this. One thing that has changed though.
color - The color of the glow, default: 0xCC0000.
To import use import flash.filters.GlowFilter;
The glow filter is used to make objects glow.
Example:
import flash.filters.GlowFilter;
var filter:GlowFilter = new GlowFilter(0xFFFF00, 100, 50, 50, 2);
mc.filters = [filter];

This will make the mc looks like it's glowing.

Gradient Glow
Syntax: GradientBevelFilter(distance:Number, angle:Number, colors:Array, alphas:Array, ratios:Array, blurX:Number, blurY:Number, strength:Number, quality:Number, type:String, knockout:Boolean);
distance - How far from the object the gradient glow will be. For a glowing look have 0, but for more shadowy look you can change it.
angle - Like in shadow, wont make any difference if distance is 0.
colors - An array with the colors the gradient will be between.
alphas - The alpha array of the colors in the colors array.
ratios - An array with the space between the colors.
type - Instead of the boolean inner used before you here use string with values "inner" or "outer".
And the rest of the parameters is mentioned before.
To import use import flash.filters.GradientGlowFilter;
Gradient glow filter is kinda like drawing with radials in Flash but with a option to be outside of the object.
Example:
import flash.filters.GradientGlowFilter;
var filter:GradientGlowFilter = new GradientGlowFilter(0, 45, [0xFFFFFF, 0xFF0000], [0, 1], [0, 255], 10, 10, 2, 3, "outer");
mc.filters = [filter];

This will make a gradient glow.

Bevel
Syntax: BevelFilter(distance:Number, angle:Number, highlightColor:Number, highlightAlpha:Number, shadowColor:Number, shadowAlpha:Number, blurX:Number, blurY:Number, strength:Number, quality:Number, type:String, knockout:Boolean);
highlightColor - The color that will be on the top and the left.
highlightAlpha - The alpha of the highlight color.
shadowColor - The color that will be on the bottom and on the right.
shadowAlpha - The alpha of the shadow color.
type - Mentioned before but I reccomend using "inner" here (which is default) because "outer" just looks bad.
To import use import flash.filters.BevelFilter;
Bevel is nice for either buttons or just to make something look 3d.
Example:
import flash.filters.BevelFilter;
var filter:BevelFilter = new BevelFilter(4, 45, 0xFFFFFF, 100, 0x000000, 100, 10, 10, 2, 3);
mc.filters = [filter];

Makes the object look 3d. :)

Wrote this pretty fast so it may be errors, inform me!
By the way, in my examples I have used a movieclip. Remember that you can also use a button or a text as long as you instance name it.

//GuyWithHisComp

AS: Filters


BBS Signature

Response to AS: Filters 2006-06-11 11:50:16


Already been done, but it's always useful. :p

Nice tut.


BBS Signature

Response to AS: Filters 2006-06-11 11:52:40


At 6/11/06 11:49 AM, GuyWithHisComp wrote: Great tut ONLY FOR FLASH 8+

Makes me wish I have Flash 8 :(

Response to AS: Filters 2006-06-11 11:53:21


At 6/11/06 11:50 AM, -Toast- wrote: Already been done, but it's always useful. :p

I already knew that but if you would've read my tutorial:

At 6/11/06 11:49 AM, GuyWithHisComp wrote: I know Inglor has made a AS:Filters before but he only included two where one didn't work so here is a bigger list of filters.

BBS Signature

Response to AS: Filters 2006-06-11 12:01:43


At 6/11/06 11:53 AM, GuyWithHisComp wrote: if you would've read my tutorial:

What, you mean you actually write AS tutorials for people to read it?! You're weird. :S


BBS Signature

Response to AS: Filters 2006-06-11 12:08:03


this could be very useful- doing these effects with as
thanks