00:00
00:00
Newgrounds Background Image Theme

Patrick8008 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!

Foss:fantastic Filter Fun!!(flash8)

2,059 Views | 21 Replies
New Topic Respond to this Topic

Foss: Main
Here i will post all my filter realted codes. i only have one right now because i'm still improving on my others.

first off

Directional Blur!!!
this took shit loads of time to learn. but since this is a FOSS thread and not an AS thread, i really dont have to explain it. But basically, it takes the movieClip you what to directionally blur, draws a bitmap version of it, rotates it using the matrix rotation and translation formula(that i just learned about in school :D) it then applies a blur filter to it, only in the horizontal direction thus to keep it linear looking. then it rotates the movieClip containing the bitmap in the desired angle so that the bitmaps rotation cancels out and becomes 0, but the blur filter is rotated still.

and if your wondering why i had to create a bitMap of the object it's because vector'd drawing's cant rotate theyre filters. even if the filters are on a movieclip inside of it.

The Code

put this code on the first frame of your movie

import flash.geom.*;
import flash.display.BitmapData;
import flash.filters.BlurFilter;
_root.myBlurPoint = new Point(0, 0);
MovieClip.prototype.directionalBlur = function(distance, angle, qual) {
this._visible = false;
wide = (distance * qual) + this._width;
high = (distance * qual) + this._height;
myBitmapData = new BitmapData(wide, high, true, 0);
Mc = _root[this._name + "Mc"];
_root.createEmptyMovieClip(this._name + "Mc", 1);
Mc.createEmptyMovieClip("image", 5);
Mc.image.attachBitmap(myBitmapData, 2, false, true);
Mc.image._x = wide / -2;
Mc.image._y = high / -2;
myMatrix = new Matrix();
myBlurRect = myBitmapData.rectangle;
myBlurFilter = new BlurFilter(distance, 0, qual);
Mc._x = this._x;
Mc._y = this._y;
myMatrix.identity();
myMatrix.rotate(-angle / 180 * Math.PI);
myMatrix.translate(wide / 2, high / 2);
myBitmapData.fillRect(myBitmapData.rectang
le, 0);
myBitmapData.draw(this, myMatrix);
myBitmapData.applyFilter(myBitmapData, myBlurRect, _root.myBlurPoint, myBlurFilter);
Mc._rotation = angle;
};

and to call it just put this on the movieclip you wish to blur

this.directionalBlur(#, #, #);
//here is what the #'s represent, in order; distance, angle, quality

sample

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-14 22:18:12


sweet....

gad dam i need flash 8 :(

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-14 22:28:19


oh and i forgot to say, go ahead and submit your own

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-14 23:21:33


At 11/14/05 10:28 PM, ImpotentBoy2 wrote: oh and i forgot to say, go ahead and submit your own

that actually produces a very cool effect. im sure that would lag if overused, but as it is, it looks great. another great FOSS...


BBS Signature

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-15 19:39:42


this next one makes a glow filter that fluxuates between 2 different colors. great for a "charging up" kinda look.

onClipEvent (load) {
period = .5;
// amount of seconds to complete one color changing cycle
import flash.filters.GlowFilter;
// allows you to use the glow filter
var myFilters:Array = this.filters;
glow = myFilters.length;
myFilters[glow] = myGlowFilter = new GlowFilter(0, 0, 0, 0, 0, 0);
//creates blank filter
color1 = 0x00CCFF;
//first color
color2 = 0x0099FF;
//second color
red1 = color1 >> 16;
red2 = color2 >> 16;
green1 = (color1 - (red1 << 16)) >> 8;
green2 = (color2 - (red2 << 16)) >> 8;
blue1 = color1 - (red1 << 16 | green1 << 8);
blue2 = color2 - (red2 << 16 | green2 << 8);
//individual RGB color values
}
onClipEvent (enterFrame) {
percent = (Math.sin(((getTimer() / 1000)) * Math.PI / period) + 1) / 2;
//makes a variable thats cycles from 0 to 1 back to zero
red = (percent * (red1 - red2)) + red2;
// currect red value
green = (percent * (green1 - green2)) + green2;
//current green value
blue = (percent * (blue1 - blue2)) + blue2;
//current blue value
myFilters[glow] = new GlowFilter(red << 16 | green << 8 | blue, 1, 25, 25, 4, 2);
this.filters = myFilters;
// aplies the filter
}

if you want i'll try and make a function for this.

also i have a question. is there a game out yet that uses alot of coded filters in a practical way (like not the showing off filters but accually utilizing is as part of the game)? cuz im hoping to kinda break new ground with these filters.

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-15 20:05:36


Sample for color one please :D. BTW! The blur filter is AWESOME!! I wonder how the code works :/. I wouldn't understand even if i looked at it :P.

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-15 20:13:10


Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-26 15:52:00


OMFG !!! THATS FUCKING OWNAGE <said good?:)>
i will make game on it!!!!

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-27 12:38:02


great coding!

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-27 12:43:22


how did you ever manage to code these? There bloody brilliant, please you have to make more. :)

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-29 02:24:09


Is there any way you could make an entire movie become black and white through coding? I know it's possible through filters (by reducing saturation, obviously) but is there anyway to do it with actionscript?

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-29 11:24:01


At 11/29/05 02:24 AM, superbrightfuture wrote: Is there any way you could make an entire movie become black and white through coding? I know it's possible through filters (by reducing saturation, obviously) but is there anyway to do it with actionscript?

not that i know of, its not something you can do with a colour transform since reducing to grey scale is done by putting saturation to 0, something which cant be done with the colour transform, so yeh, you have to use a filter (which can also be done through as)

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-29 11:26:44


At 11/29/05 11:24 AM, -dELta- wrote: not that i know of...
yeh, you have to use a filter (which can also be done through as)

lol... contradiction is fun ^^;
i guess all the cool kids use flash 8 now. thats what i need


BBS Signature

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-29 11:55:17


pretty nifty, thanks

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-29 12:41:19


useful for just about any moving. nice one :)

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-29 13:23:26


**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Statement must appear within on handler
this.directionalBlur(10, 10, 10);

Total ActionScript Errors: 1 Reported Errors: 1

Im using flash 8, the main code is on my 1st frame, and this is on my movie clip:
this.directionalBlur(10, 10, 10);

wots wrong??

nice effect tho

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-29 13:30:05


Wow that really impressed me, that looks like a perfect motion blur and all real time, the frame rate was great also, very smooth and slick!

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-29 13:40:44


At 11/29/05 01:23 PM, FlyingPika wrote: **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Statement must appear within on handler
this.directionalBlur(10, 10, 10);

Total ActionScript Errors: 1 Reported Errors: 1

Im using flash 8, the main code is on my 1st frame, and this is on my movie clip:
this.directionalBlur(10, 10, 10);

wots wrong??

nice effect tho

according to the error, you have that code on the movieclips actions and without a handler of on(load) or on(enterFrame) etc, i.e. put it inside the on(load) / on(enterFrame) / etc.

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-29 13:43:07


At 11/29/05 01:23 PM, FlyingPika wrote: wots wrong??

onClipEvent(load){
this.directionalBlur(10, 10, 10);
}


BBS Signature

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-30 01:14:44


At 11/29/05 11:24 AM, -dELta- wrote:

Is there any way you could make an entire movie become black and white through coding? I know it's possible through filters (by reducing saturation, obviously) but is there anyway to do it with actionscript?

not that i know of, its not something you can do with a colour transform since reducing to grey scale is done by putting saturation to 0, something which cant be done with the colour transform, so yeh, you have to use a filter (which can also be done through as)

i.e. you CAN do it. right? but how do I use a filter throught as?

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-30 06:57:35


At 11/30/05 01:14 AM, superbrightfuture wrote: i.e. you CAN do it. right? but how do I use a filter throught as?

Flash 8 filters by Inglor

Response to Foss:fantastic Filter Fun!!(flash8) 2005-11-30 10:07:29


At 11/30/05 06:57 AM, Creeepy wrote:
At 11/30/05 01:14 AM, superbrightfuture wrote: i.e. you CAN do it. right? but how do I use a filter throught as?
Flash 8 filters by Inglor

... but that didn't tell how to do it with colour...