# One animated filter, multiple buttons

**URL:** <https://forum.kirupa.com/t/one-animated-filter-multiple-buttons/194800>\
**Category:** Uncategorized\
**Created:** [July 26, 2006, 12:49pm UTC](https://forum.kirupa.com/t/one-animated-filter-multiple-buttons/194800 "2006-07-26T12:49:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![takethetrain](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@takethetrain](https://forum.kirupa.com/u/takethetrain)\
**Post date:** [July 26, 2006, 12:49pm UTC](https://forum.kirupa.com/t/one-animated-filter-multiple-buttons/194800/1 "2006-07-26T12:49:25Z")

</div>

I have a filter I’ve applied to multiple buttons, and it animates (using onEnterFrame) with onRollOver and onRollOut functions applied to each button. The problem is, sometimes when I roll over one button, it also animates the filter on another button (because they are using the same filter).

I know the obvious solution is to have a different filter applied to each button, but I’m concerned that this would slow things down. Also, I can’t help but think there is another way to solve this, particularly because this issue only occurs _some_ of the time, not all of it.

Here is the AS code. I’ve included a small sample file to illustrate the problem I’m having.

```auto

import flash.filters.*;
var buttonShadow:DropShadowFilter = new DropShadowFilter(0, 0, 0x000000, 20, 5, 5, 5, 3, false, false, false);
b1.filters = b2.filters = [buttonShadow];
var buttonOver = function (targetMC) {
	targetMC.onEnterFrame = function() {
		buttonShadow.blurX += (20 - buttonShadow.blurX) / 5;
		buttonShadow.blurY = buttonShadow.blurX;
		targetMC.filters = [buttonShadow];
		if (buttonShadow.blurX == 20) {
			delete targetMC.onEnterFrame;
		}
	};
};
var buttonOut = function (targetMC) {
	targetMC.onEnterFrame = function() {
		buttonShadow.blurX += (5 - buttonShadow.blurX) / 5;
		buttonShadow.blurY = buttonShadow.blurX;
		targetMC.filters = [buttonShadow];
		if (buttonShadow.blurX == 5) {
			delete targetMC.onEnterFrame;
		}
	};
};
b1.onRollOver = b2.onRollOver = function() {
	buttonOver(this);
}
b1.onRollOut = b2.onRollOut = function() {
	buttonOut(this);
}

```

Thanks!
