Skip to main content
Trocergian
Known Participant
May 2, 2009
Answered

Clearing a filter

  • May 2, 2009
  • 2 replies
  • 742 views

This is one of those things that drives me nutty as it seems like it should be obvious but I've spent the last 30 minutes searching for an answer and have come up empty.

How do I clear a filter after having applied it to an object. In particular, I'm bluring an object while animating it but want to clear the blur once it's hit the destination mark.

It's being applied via:

[object_in_question].filters = [BlurAmount];

This topic has been closed for replies.
Correct answer Colin Holgate
Although setting it to null would remove all filters, sometimes you only want to remove the temporary filter. The filters are an array, so if you wanted to have a drop shadow all the time, and a blur sometimes, you could do this kind of thing:
var stationaryFilters:Array = [dropshadowfilter];
var movingFilters:Array = [dropshadowfilter,blurfilter];
where the two entries are filters you've already set up. Then when you move, you would say:
mc.filters = movingFilters;
and when you stop you say:
mc.filters = stationaryFilters;
So, thinking in terms of it all being an array, I would tend to say:
mc.filters = [];
rather than
mc.filters = null;
even if the two would both remove all filters.
Another trick to think about is that you could manually set up a complex set of filters on a movieclip on the stage, until you like the look of it, and then when you want another movieclip to have the same effects, you could say:
mc.filters = fancyStageMC.filters;
and all of the values would take effect immediately. Working this way means you can get the look that you like without having to spend a while trying all sorts of parameters in your code.

2 replies

Colin Holgate
Colin HolgateCorrect answer
Inspiring
May 2, 2009
Although setting it to null would remove all filters, sometimes you only want to remove the temporary filter. The filters are an array, so if you wanted to have a drop shadow all the time, and a blur sometimes, you could do this kind of thing:
var stationaryFilters:Array = [dropshadowfilter];
var movingFilters:Array = [dropshadowfilter,blurfilter];
where the two entries are filters you've already set up. Then when you move, you would say:
mc.filters = movingFilters;
and when you stop you say:
mc.filters = stationaryFilters;
So, thinking in terms of it all being an array, I would tend to say:
mc.filters = [];
rather than
mc.filters = null;
even if the two would both remove all filters.
Another trick to think about is that you could manually set up a complex set of filters on a movieclip on the stage, until you like the look of it, and then when you want another movieclip to have the same effects, you could say:
mc.filters = fancyStageMC.filters;
and all of the values would take effect immediately. Working this way means you can get the look that you like without having to spend a while trying all sorts of parameters in your code.

Trocergian
Known Participant
May 2, 2009

Dang, just didn't have the array mindset going when I was trying to clear the filters, even though I needed that mindest when I was applying the darn thing.

Thanks guys, man I love this forum!

kglad
Community Expert
Community Expert
May 2, 2009

assign it to null.

[object_in_question].filters = null;