• Home
  • Free Tutorials
  • Free Video Tutorials

Adobe Photoshop
Autodesk 3ds Max
CSS
Flash
Help Center Live
iPhone
Joomla
Make Money Online!
Mambo
mIRC
Outlook Express
SEO / SEM
Simple Machine Forum
Target Explorer

Dynamic Blur Effect with Actionscript

Category : Flash Views : 19089
Version : 8 Rating : 
3.2/5 (39 votes)
  • Currently 3.23/5
  • 1
  • 2
  • 3
  • 4
  • 5
Type : Text Source File: dynamic-blur-effect-with-actionscript.zip
Result: See the result


Previous | 1 | 2 | Next

Code Explanation

import flash.filters.BlurFilter;
Import the BlurFilter class, this class allows us to change or add blur to Movie Clips or textboxs.

var blur_X = 10; var blur_Y = 10;
The default blur value in the _x and _y coordinate.

var quality = 5;
This variable is the quality of the blur filter.

var filter = new BlurFilter(blur_X, blur_Y, quality);
Create a new blur filter to add to the Movie Clip.
Parameters for the object:
BlurFilter(_x blur, _y blur, quality).

var filterAr = new Array();
Every Movie Clip has an array of filters they have, we need to create our own array to substitute for the original in the Movie Clip.

filterAr[0] = filter;
Set the blur filter we created to the first element in our array of filters, if you wanted to use other filters on the same time just assign them to a different position in the array.

image.filters = filterAr;
Make the array of filters in the Movie Clip equal to our array.

_root.onEnterFrame = function() { if (image.hitTest(_xmouse, _ymouse, true)) {
If the mouse is over the image Movie Clip run this code.

if (image.filters[0].blurX != 0) { blur_X -= 1; blur_Y -= 1;
If the property "blurX" in the first filter of the Movie Clip is different than 0 decrease the blur_X and the blur_Y variables by one.

filter = new BlurFilter(blur_X, blur_Y, quality);
Recreate the BlurFilter object with the new parameters.

filterAr = new Array(); filterAr[0] = filter; image.filters = filterAr;
Create a new array, attach the Blur filter to it and then change the Movie Clip's filter array, exactly like we did previously.

} } else { if (image.filters[0].blurX != 10) {
If the mouse is not over the image and the "blurX" property of the blur filter is not equal to 10 run this.

blur_X += 1; blur_Y += 1;
Increase blur variable to attach to the Movie Clip.

filter = new BlurFilter(blur_X, blur_Y, quality); filterAr = new Array(); filterAr[0] = filter; image.filters = filterAr; } } }
Recreate the blur filter and change the Movie Clip's filter array.


More cool tech articles from other blogs.

Place your ad here
Loading...


Previous | 1 | 2 | Next
How to Video Tutorials on software by Helpvids.com

Sponsors





Studio | Advertisement | About Webzo | Contact Webzo | Terms of Use | Free Video Tutorials by Helpivds

Copyright © 2007 NR Concepts Ltd. All rights reserved.