Saturday, January 16, 2010

AS 3.0 : Quick + Easy BLUR script

After an exhaustive and futile search for what ought to be an easy method to a common task, I turned reluctantly to Adobe Livedoc* and extracted the necessary syntax from its unnecessarily dense documentation. I present to you a timeline-based method of scripting a 'Blur Effect'.

//1. You'll need these import statements at the very top of the actionscript panel of the 1st frame of the Main timeline.
import flash.display.Sprite;
import flash.filters.BitmapFilter;
import flash.filters.BitmapFilterQuality;
import flash.filters.BlurFilter;

/*Next I create a reusable function that accepts three parameters: The name of your Clip, How much to Blur the X, How much to Blur the Y*/

function BlurIt(ClipName,BlurXValue,BlurYValue) {
var blurX:Number=BlurXValue;
var blurY:Number=BlurYValue;

//Next Line -> Essence of the Blur Method:
var myBlur:BlurFilter= new BlurFilter;(blurX,blurY,BitmapFilterQuality.HIGH);
//attach the method to the Object (your movieclip)..
ClipName.filters=[myBlur];
}
//3. Blur Function ready for use.
BlurIt(ClipName,BlurX,BlurY);

//Example :

BlurIt(myNwee,20,20);

If you're copying the codes, you may exclude the '//' comments.

No comments:

Post a Comment