Focus in on an Image
Description: Start out with a blurred image and focus in on it.
Author: John Bezanis
Added: January 31st 2007
Version: Flash 8
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:
- //this section is processed once
- onClipEvent(load){
- //Import the BlurFilter class so we can use actionscript to create blurs
- import flash.filters.BlurFilter;
- //Distance to blur
- var blurX:Number = 100;
- var blurY:Number = 100;
- //Number of times to apply the blur.
- var quality:Number = 2;
- //Create the filter
- var filter:BlurFilter = new BlurFilter(blurX, blurY, quality);
- //apply the filter
- this.filters=[filter];
- //the image is reset after 200 frames
- var delayToReset:Number=200;
- }
- //load on each frame
- onClipEvent(enterFrame){
- //if the image isn't completely focused
- if(blurX>0&&blurY>0){
- //if the image is more blurred, focus in faster
- if(blurX>20&&blurY>20){
- filter.blurY-=1;
- filter.blurX-=1;
- }else{
- filter.blurY-=.05;
- filter.blurX-=.05;
- }
- //apply the new blurX and blurY amounts
- this.filters = [filter];
- }
- //decrement the delay to reset
- delayToReset-=1;
- //200 frames have passed. Reset the blur
- if(delayToReset<1){
- delayToReset=200;
- filter.blurY=100;
- filter.blurX=100;
- this.filters = [filter];
- }
- }
The source file is available below for download.
Download Source File
Comments
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.
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...............??
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............
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
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
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
exactly what I was looking for but... how do I make it focus faster?
March 29th 2009 12:03PM - almost there
Oh googling flasher passing in the night, I found out how to make it focus faster...
change....
if(blurX>20&&blurY>20){
filter.blurY-=1;
filter.blurX-=1;
to...
if(blurX>20&&blurY>20){
filter.blurY-=8;
filter.blurX-=8;
change....
if(blurX>20&&blurY>20){
filter.blurY-=1;
filter.blurX-=1;
to...
if(blurX>20&&blurY>20){
filter.blurY-=8;
filter.blurX-=8;
April 8th 2009 04:04PM - almost there
you want the free code and an image of your choice!
You could also have told steven speilberg to use snakes in jurrasic park back in 90's !!
You could also have told steven speilberg to use snakes in jurrasic park back in 90's !!
October 16th 2009 08:10PM - insanep
I have bookmarked your site. Thanks for sharing
December 13th 2009 08:12AM - dental
Good but i think the coding should be a little more be reduce.
January 12th 2010 08:01PM - best cricket phones
Thanks for this great share :)
January 24th 2010 09:01AM - Acai Berry 6
Image above is very beautiful.
January 25th 2010 11:01PM - film
What is a sexy girl's name in image above?
January 25th 2010 11:01PM - book
Special thank for good post.
February 5th 2010 09:02PM - โหลดเพลงà
Thank for the information
February 6th 2010 07:02AM - โหลดเพลงm
Leroy, tutorials are for LEARNING. You don't learn if you don't try to understand it! You should know what each part does, so you can adjust it to your project. Otherwise, it's almost plagiarism!
February 6th 2010 12:02PM - Jeffrey
Special thank for good post.
February 10th 2010 04:02AM - โหลดเพลงà
Special thank for good post.
February 10th 2010 08:02AM - โหลดเพลงà
Add a Comment






Sorry, I'm newbee in Flash.