WhiteKnight
05-30-2008, 05:33 PM
Well I promised that I would post some flash tuts and stuff, and I doubt anyone will use this, but here...
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 (http://www.bezzmedia.com/swfspot/resources/11-focusin.fla)
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 (http://www.bezzmedia.com/swfspot/resources/11-focusin.fla)