The BlurFilter is simply something I love.
I"ve created an example on how to apply the BlurFilter to our MovieClip with Actionscript 3.0 and I"ve played a little with it.
Let"s see how I"ve done it"
Code:
package
{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.Event;
import flash.geom.Point;
import flash.filters.BlurFilter;
public class Bluring extends MovieClip
{
private var clips_array:Array;
private var fields_array:Array;
private var arrX:Number;
private var arrY:Number;
public function Bluring()
{
stage.frameRate=31;
init();
initListener();
}
private function init():void
{
clips_array=new Array(clip_0_mc,clip_1_mc,clip_2_mc,clip_3_mc,clip_4_mc);
fields_array=new Array(tag_0_mc.info_txt,tag_1_mc.info_txt,tag_2_mc.info_txt,
tag_3_mc.info_txt,tag_4_mc.info_txt);
}
private function initListener():void
{
addEventListener(Event.ENTER_FRAME,controllaMouse);
}
private function controllaMouse(e:Event):void
{
var point:Point=new Point(mouseX,mouseY);
for(var i:int=0;i < clips_array.length;i++)
{
var scalingX:Number=12-clips_array[i].scaleX*6;
var scalingY:Number=12-clips_array[i].scaleY*6;
fields_array[i].text='BLUR = '+(scalingX.toFixed(2)).toString();
getFilter(scalingX,scalingY,clips_array[i]);
if(clips_array[i].hitTestPoint(point.x,point.y,false))
sottoFocus(clips_array[i]);
else
libero(clips_array[i]);
}
}
private function sottoFocus(m:MovieClip):void
{
var arrS:Number=200;
var ds:Number=arrS-m.scaleX*100;
var xs:Number=ds*.2;
m.scaleX+=xs/100;
m.scaleY+=xs/100;
}
private function libero(m:MovieClip):void
{
var arrS:Number=100;
var ds:Number=arrS-m.scaleX*100;
var xs:Number=ds*.2;
m.scaleX+=xs/100;
m.scaleY+=xs/100;
}
private function getFilter(xx:Number,yy:Number,m:MovieClip):void
{
var array_filter:Array=new Array();
var quality:int=2;
var filter:BlurFilter=new BlurFilter(xx,yy,quality);
array_filter.push(filter);
m.filters=array_filter;
}
}
}
The juice of this script ( which I"ve probably fattened too much and the beginners might find difficulty in translating it ) is made of how to apply the BlurFilter to a MovieClip, like so:
You need to pass the internal filter of an Array to the filters property of the MovieClip.
I create an array:
var array_filter:Array=new Array();
I create a filter ( in this case the BlurFilter ):
var filter:BlurFilter=new BlurFilter(10,10,1);
I insert the filter inside the Array:
array_filter.push(filter);
I pass the Array to the MovieClip:
nameClip.filters=array_filter;
Stay tuned !