|
||||||
|
||||||
Flash - Blurring a Picture

Free
Flash Tutorial
![]()
The aim of the tutorial is to learn how to make a Movie Clip blur in various ways: You will learn how to create a transition effect between an image in focus and a blurred image either by using an animated Tween effect or by using ActionScript.
Example: Download
the Flash file Int 127a
Method 1: Blurry
Cat using Tweening to create animated transition.
Note: For Method 1: See Steps 1 to 5
Example: Download
the Flash file Int 127b
Method 2: Same
as above but using ActionScript to create transition effect.
Note: For Method 2: See Steps 6 to 7
Example: Download
the Flash file Int
127c
There is no reason why the effect cannot be reversed.
Method
1: Blurry
Cat using Tweening
Step One: Blurring an Image
Note: In PhotoShop to blur an image go to: Filter > Blur > Gaussian Blur
Original Blurred Note: if you wish to use these images right click (Mac: Ctrl click) on the images and select: Save Picture As...
Step Two: Setting Up the Main Stage
Note: I made my Flash Movie 20 pixels higher and wider than the original images.
My document size is: 220 x 170 pixels
Both my Images are: 200 x 150 pixels


Step Three: Creating the Symbols needed for the Animated Blur Effect



Step Four: Creating the Animated Blur Effect - Method 1: Tweening
Important Note: If you wish to use the ActionScript Method (2) to create the Blur Effect skip this Step (four) and continue from Step five below.
Note: You will see a layer named "Layer 1" with one Frame containing the Movie Clip: MC Cat




Note for Flash MX: If you are using Flash MX you will need to be in Expert Mode to type:
The View Options Menu in the Actions Panel for Flash MX.




Note: Changing the Alpha effects a Movie Clips transparency. So setting it to zero makes the image completely transparent or invisible.
Step Five: The Invisible Button
Note: If you are using the ActionScript Method (2) to create your Movie you continue the tutorial from this Step.



Note: This semi-transparent turquoise is an Invisible Button. It will hold some Actionscript code. The turquoise area represents the active hit area (set to exactly the same size as the original and blurred cat clips).
Note: You do not need to type in the comments: // Grayed out text.
on (rollOver) { //setup a Rollover event for the button clip
currframe = _root.cat._currentframe; //currframe represents the frame that is currently playing in the "cat" clip at the time you move your cursor over the "button" clip
displacement = Math.abs(currframe-10); //displacement represents the number of frames the Play Head is from the visible image in frame 10 in the MC Cat symbol. Frame 10 is the frame in which the "MC Cat" is completely visible, having an alpha of 100%.
if (currframe == 1 || currframe == 10) { //if currframe is at the first frame (Frame 1, invisible) or at Frame 10 (completely visible) , let "cat" play.
_root.cat.play(); //then allow "cat" to play
}
if (currframe == 20) { //if you are at frame 20 of "cat" (i.e., currframe==20), "rewind" "cat" by playing it from frame 2.
_root.cat.gotoAndPlay(2);
}
if (currframe>10) { //if currframe greater than 10 (you are starting to fadeout). where you left off from fading out.
_root.cat.gotoAndPlay(10-displacement); // This controls the position of the Play Head. The Play Head or place that the animation plays from will depend to the amount of fade out the animation previous reached. So if the image was very blurred it will come back into focus form a very blurred image and visa versa. To realise this effect I have used a variable called: displacement.
}
}
on (rollOut)
{ //setup a Rollout event for the button
clip
currframe = _root.cat._currentframe; //defines the variable called: currframe
displacement = Math.abs(currframe-10); // defines the variable called: displacement
if (currframe <= 10) { //this time, if you rollout while fading in, start to fadeout.
_root.cat.gotoAndPlay(10+displacement);
}
}
on (release, releaseOutside)
{
trace("Meow!"); //put your own code here to do something like: gotoAndPlay etc.
}
Note: In the ActionScript above to type the line: | use: Shift + Back Slash \
Method 2: Blurry Cat using ActionScript Fading
If you have used the Tweening Method (1) and followed all the steps above you have finished your Movie. For Method 2 you need to complete Steps 1 to 5 above except for step 4.
Step Six: The Button ActionScript
on (rollOver) { //when you rollover set the variable dir (which stands for "direction of fade"). In this case a dir of 1 will make the "Cat Fader" clip fade in (see below to see how dir affects the fading).
_root.dir = 1;
}
on (rollOut) { //upon rollout, change dir to -1 for a fadeout of "Cat Fader" (see below...)
_root.dir = -1;
}
on (release, releaseOutside) {
trace("Meow!"); //put your code to do something, like gotoAndPlay to another frame of your choice, here.
}
Step Seven: The Movie Clip ActionScript
onClipEvent (load) { //sets the initial condition of the "Cat Fader" clip. In this case we want the clip to be invisible. We also want to setup a variable, named speed, to represent the amount of alpha shed or gained by the clip in every frame.
this._alpha = 0;
_root.speed = 15;
}onClipEvent (enterFrame) { //setup an onClipEvent EnterFrame function for the clip that checks to see what value the alpha of the clip is at (represented by this._alpha)
if (this._alpha < 0) { //if the alpha is less than zero set it to zero. (I know this sounds silly, but it can exist this way without immediate, obvious effect. Without this check it is possible to delay the fade-in since the alpha continues to drop numerically). Then set the direction (i.e., dir) to zero to prevent the alpha of the clip from changing until dir has a value of plus or minus 1.
this._alpha = 0;
_root.dir = 0;
}
if (this._alpha > 100) { //if the alpha is >100, set the alpha to 100 and set dir to 0 to prevent the alpha of the clip from changing until dir has a value of plus or minus 1.
this._alpha = 100;
_root.dir=0;
}
this._alpha = this._alpha + (_root.dir*_root.speed); //if the alpha of the clip is between 0 and 100, increment the clips alpha by the value of speed.
}
That's it for Method 2. You should now test your Movie. As always, I hope you enjoyed the tutorial, and found it easy to follow. Thank you for your time!
Cross Ref: There is also a tutorial on how to create Animated Blurred Text which rushes on and off stage: Animated Blurred Text
Why not try out webwasp's new community. Meet new people, find friends in your area: Webwasp Mates & Dates
|
|
|
All material on this site is protected under international copyright © law. DO NOT reproduce any material from this site without written permission. Please ask as permission is often granted.
|