Newest Articles

8 Ball Pool
Photo Reel
Image Color Tinting using Actionscript
3d Rotating Image Cube
Image Slider with Easing
Catapult Game


Popular Articles

True Fullscreen Flash Mode
8 Ball Pool
FLV Player
Image Slider
Mp3 Player with XML Playlist
Album Slide


Random Articles

Catapult Game
Space Shooter Game
Picture Puzzle
Focus in on an Image
Mouse Following Preloader
Image Slider with Easing


Links

Foundation-Flash
Tutorial4Me
MickM
TutorialQuest
Tutorialsphere.com - Free Online Tutorials
Newgrounds
TWiT
Link to SwfSpot
Swf Spot



rss feed

Focus in on an Image

Focus in on an Image
AddThis Social Bookmark Button
Description: Start out with a blurred image and focus in on it.
Author: John Bezanis
Added: January 31st 2007
Version: Flash 8
Total Views: 9476
Views in the Past 7 Days: 90


This is a simple focus in effect purely using Actionscript. First, draw your object on the screen, or use File->Import to Stage to import an image. Right-click the object and hit convert to symbol. Set the type to movie clip and click Export for ActionScript. Now single-click the new symbol and insert the following code into the Action tab:
  1. //this section is processed once
  2. onClipEvent(load){
  3.   //Import the BlurFilter class so we can use actionscript to create blurs
  4.   import flash.filters.BlurFilter;
  5. //Distance to blur
  6.   var blurX:Number = 100;
  7.   var blurY:Number = 100;
  8. //Number of times to apply the blur.
  9.   var quality:Number = 2;
  10. //Create the filter
  11.   var filter:BlurFilter = new BlurFilter(blurX, blurY, quality);
  12. //apply the filter
  13.   this.filters=[filter];
  14. //the image is reset after 200 frames
  15.   var delayToReset:Number=200;
  16. }
  17. //load on each frame
  18. onClipEvent(enterFrame){
  19. //if the image isn't completely focused
  20.   if(blurX>0&&blurY>0){
  21. //if the image is more blurred, focus in faster
  22.     if(blurX>20&&blurY>20){
  23.       filter.blurY-=1;
  24.       filter.blurX-=1;
  25.     }else{
  26.       filter.blurY-=.05;
  27.       filter.blurX-=.05;
  28.     }
  29. //apply the new blurX and blurY amounts
  30.     this.filters = [filter];
  31.   }
  32. //decrement the delay to reset
  33.   delayToReset-=1;
  34. //200 frames have passed. Reset the blur
  35.   if(delayToReset<1){
  36.     delayToReset=200;
  37.     filter.blurY=100;
  38.     filter.blurX=100;
  39.     this.filters = [filter];
  40.   }
  41. }

The source file is available below for download.

Download Source File
Questions and Suggestions
Does this effect needs the BlurFilter? Sorry, I'm newbee in Flash.
May 28th 2007 12:05PM   -   family
Your samples is good but teaching method very bad. I tried your tutorial row by row not step by step, row by row nothing worked! so if you puit details it can be a tutorial. Noew It's only good-looking blur effect but only text.
June 9th 2007 01:06AM   -   Gulek Kandirali
Use the sweet photo......... what a velgarity is this...............??
June 29th 2007 07:06AM   -   Dharam
It's true that you effect is good , but use the nice phot like a car or any thing else... realy nice effect............
June 29th 2007 07:06AM   -   Dhram
Cool tutorial, I've been looking for a quick and easy effect like this. @Previous posters: try going back and learning some basics if you have trouble following this cut&paste snippet...
August 10th 2007 04:08AM   -   Visionary
I couldnt understand why did u write tones of code instead of doing it with a few mouse clicks... I guess u like coding more than using your mouse :)But i think it s a bit of wasting time... Anyways, nice tutorial, thank you
October 22nd 2007 04:10AM   -   Barbaros
Very nice tutorial :)copy past your done :) all tutorials need to be like that :P
December 5th 2007 09:12AM   -   Leroy
Well done and thanks!!I´m so sorry people who´s going to use your tutorial are talking about the photo..hehe..so..why not?isn´t it awsome? ;)Thanks for sharing
March 24th 2008 08:03AM   -   Michelle
Cool tutorial, I've been looking for a quick and easy effect like this. @Previous posters: try going back and learning some basics if you have trouble following this cut&paste snippet...
April 5th 2008 07:04AM   -   Thainua
Add a Question or Suggestion
name:
website (optional):
captcha type the characters into the box
message (5000 characters or less):