# \[F8\] filters\_problem!

**URL:** https://forum.kirupa.com/t/f8-filters-problem/185112
**Category:** flash
**Created:** [April 11, 2006, 2:10am UTC](https://forum.kirupa.com/t/f8-filters-problem/185112 "2006-04-11T02:10:50Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![dec27](https://avatars.discourse-cdn.com/v4/letter/d/2bfe46/32.png) [@dec27](https://forum.kirupa.com/u/dec27)
#### Post date: [April 11, 2006, 2:10am UTC](https://forum.kirupa.com/t/f8-filters-problem/185112/1 "2006-04-11T02:10:50Z")

</div>

Hi!

I would like to know if there’s a way to apply a filter to many mc’s.  
I’ve been looking for tutorials and examples, but the filter is applied only to one item.  
So I would like to know if I can use a function to apply the same filters with to many mc’s.  
I know how to apply only to one, but should I use the same code and repeat it for all the rest?

```auto

import flash.filters.BlurFilter;
var bf:BlurFilter = new BlurFilter(10, 10, 1);
target_mc.filters = [bf];
function noblur(target){
target_mc.onRollOver = function() {
	this.onEnterFrame = function() {
		if (bf.blurX>1) {
			bf.blurX--;
			bf.blurY --;
		} else {
			delete this.onEnterFrame;
		} 
		this.filters = [bf];
		target.onRollOut = function() {
			this.onEnterFrame = function() {
				this.filters = [bf];
				if (bf.blurX<10) {
					bf.blurX++;
					bf.blurY=bf.blurX;
				} else {
					delete this.onEnterFrame;
				}
			};
		};
	};
};
}

```

Thanks in advanced.

---

<div class="post-metadata">

### Author: ![dec27](https://avatars.discourse-cdn.com/v4/letter/d/2bfe46/32.png) [@dec27](https://forum.kirupa.com/u/dec27)
#### Post date: [April 11, 2006, 6:00pm UTC](https://forum.kirupa.com/t/f8-filters-problem/185112/2 "2006-04-11T18:00:02Z")

</div>

any advice or comment?

---

<div class="post-metadata">

### Author: ![virusescu](https://avatars.discourse-cdn.com/v4/letter/v/8edcca/32.png) [@virusescu](https://forum.kirupa.com/u/virusescu)
#### Post date: [April 11, 2006, 7:37pm UTC](https://forum.kirupa.com/t/f8-filters-problem/185112/3 "2006-04-11T19:37:40Z")

</div>

I maybe don’t understand your question exactly but, if you have let’s say 5 MCs called target1 trough target5 you apply the filter like

```auto
import flash.filters.BlurFilter;
var bf:BlurFilter = new BlurFilter(10, 10, 1);
for (var x = 1;x<=5;x++){
this["target"+x].filters = [bf];
}

```

As easy as that…

---

<div class="post-metadata">

### Author: ![dec27](https://avatars.discourse-cdn.com/v4/letter/d/2bfe46/32.png) [@dec27](https://forum.kirupa.com/u/dec27)
#### Post date: [April 11, 2006, 11:53pm UTC](https://forum.kirupa.com/t/f8-filters-problem/185112/4 "2006-04-11T23:53:43Z")

</div>

Thanks for reply!  
Surely it is easy!

But, what do I do with the onRollOver and onRollOut?  
Sorry, but I’m not that …intelligent!

```auto

import flash.filters.BlurFilter;
var bf:BlurFilter = new BlurFilter(10, 10, 1);
for (var x = 1; x<=5; x++) {
	this["target"+x].filters = [bf];
}
["target"+x]onRollOver = function() {
	this.onEnterFrame = function() {
		if (bf.blurX>1) {
			bf.blurX--;
			bf.blurY--;
		} else {
			delete this.onEnterFrame;
		}
		this.filters = [bf];
		["target"+x]onRollOut = function() {
			this.onEnterFrame = function() {
				this.filters = [bf];
				if (bf.blurX<10) {
					bf.blurX++;
					bf.blurY = bf.blurX;
				} else {
					delete this.onEnterFrame;
				}
			};
		};
	};
};

```

---

<div class="post-metadata">

### Author: ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)
#### Post date: [April 12, 2006, 12:42am UTC](https://forum.kirupa.com/t/f8-filters-problem/185112/5 "2006-04-12T00:42:33Z")

</div>

```auto
import flash.filters.BlurFilter;
for (var x = 1; x <= 7; x++) {
 var mc:MovieClip = this["target" + x];
 mc.bf = new BlurFilter(10, 10, 1);
 mc.onRollOver = function() {
  this.onEnterFrame = function() {
   if (this.bf.blurX <= 0) {
    trace(this.bf.blurX);
    delete this.onEnterFrame;
   }
   this.bf.blurX = this.bf.blurY--;
   this.filters = [this.bf];
  };
 };
 mc.onRollOut = function() {
  this.onEnterFrame = function() {
   if (this.bf.blurX >= 10) {
    trace(this.bf.blurX);
    delete this.onEnterFrame;
   }
   this.bf.blurX = this.bf.blurY++;
   this.filters = [this.bf];
  };
 };
 this["target" + x].onRollOut();
}

```

---

<div class="post-metadata">

### Author: ![dec27](https://avatars.discourse-cdn.com/v4/letter/d/2bfe46/32.png) [@dec27](https://forum.kirupa.com/u/dec27)
#### Post date: [April 12, 2006, 1:02am UTC](https://forum.kirupa.com/t/f8-filters-problem/185112/6 "2006-04-12T01:02:31Z")

</div>

Thank you very much!

Could explain a little bit, please?

:snug:

---

<div class="post-metadata">

### Author: ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)
#### Post date: [April 12, 2006, 2:09am UTC](https://forum.kirupa.com/t/f8-filters-problem/185112/7 "2006-04-12T02:09:25Z")

</div>

Sure thing:

```auto
//import BlurFilter class
import flash.filters.BlurFilter;
//loop thorugh the clips, in this case 1 through 7
for (var x = 1; x <= 7; x++) {
 //store the resolved movie clip as mc so we don't have to write as much
 var mc:MovieClip = this["target" + x];
 //give the movie clip its own blur filter, otherwise modifiy the filter would affect all of the movie clips
 mc.bf = new BlurFilter(10, 10, 1);
 //set function to execute onRollOver
 mc.onRollOver = function() {
  //onEnterFrame yadda yadda yadda
  this.onEnterFrame = function() {
   //if the mc's blur filter is less than or equal to 0, delete the onEnterFrame function
   if (this.bf.blurX <= 0) {
    trace(this.bf.blurX);
    delete this.onEnterFrame;
   }
   //set blurX equal blurY minus equal 1  
   this.bf.blurX = this.bf.blurY--;
   //set filter property of movie clip
   this.filters = [this.bf];
  };
 };
 //same deal as onRollOver but in reverse ;)
 mc.onRollOut = function() {
  this.onEnterFrame = function() {
   if (this.bf.blurX >= 10) {
    trace(this.bf.blurX);
    delete this.onEnterFrame;
   }
   this.bf.blurX = this.bf.blurY++;
   this.filters = [this.bf];
  };
 };
 //initialize the clip by calling its onRollOut function (applies filter)
 //alternatively you could've written || mc.filters = [mc.bf] || but this way looks better :)
 mc.onRollOut();
 //delete the temporary variable (which up to this point wasn't temporary :) )
 delete mc;
}
//test the movie and watch the 7 movie clips and their filters animate
//THE END!!!

```

:hoser:

---

<div class="post-metadata">

### Author: ![dec27](https://avatars.discourse-cdn.com/v4/letter/d/2bfe46/32.png) [@dec27](https://forum.kirupa.com/u/dec27)
#### Post date: [April 12, 2006, 3:02am UTC](https://forum.kirupa.com/t/f8-filters-problem/185112/8 "2006-04-12T03:02:11Z")

</div>

That’s nice from you!

You’re the man, as always!

😉
