|
||||||
|
||||||
Animating Filters with ActionScript

Free
Flash Tutorial
Step Four: Changing Multiple Parameters
In this example I change several parameters at once. Each parameter has it's own variable. Thus several variables are used to change several of the filter parameters at once.
Here is an example of several parameters animating at once:
Example: Download the Flash file Draw 220c
Click and roll over the image. The filter properties will continually change.
This is the ActionScript used to change the Glow Filter's parameters:
// Makes the filter available to use in the Movie.
import flash.filters.GlowFilter;// Creates variables that define the parameter settings
var myColor = 0x000066;
var myAlpha = 0.7;
var myBlurX = 12;
var myBlurY = 12;
var myStrength = 3;
var myQuality = 3;
var myInner = true;
var myKnockout = false;// Creates a variable with info about the Filter settings.
var myGlow = new GlowFilter(myColor,myAlpha,myBlurX,myBlurY,myStrength,myQuality,myInner,myKnockout);
// Applies the filter to the object named myObject.
myObject.filters = [myGlow];// Creates an on mouse roll-over function (event).
myObject.onRollOver = function() {
// Refreshes the function continuously.
this.onEnterFrame = function() {
// Changes the Alpha setting (transparency).
myAlpha += .02;
if (myAlpha > 1.1) {
myAlpha = 0.2;
}
// Changes the Blur setting.
myBlurX += .2;
myBlurY = myBlurX;
if (myBlurX > 50) {
myBlurX = 12;
}
// Changes the Strength setting.
myStrength += 1;
if (myStrength > 100) {
myStrength = 1;
}
// Changes the Quality setting.
myQuality += 0.2;
if (myQuality > 10) {
myQuality = 1;
}
// Re-creates a variable with info about the Filter settings.
var myGlow = new GlowFilter(myColor,myAlpha,myBlurX,myBlurY,myStrength,myQuality,myInner,myKnockout);
// Re-applies the filter to the object named myObject.
myObject.filters = [myGlow];
};
};// Creates an on mouse roll-out function (event).
myObject.onRollOut = function() {
// Refreshes the function continuously.
this.onEnterFrame = function() {
// Changes the Blur setting.
myBlurX = myBlurX - 10;
myBlurY = myBlurX;
// Re-creates a variable with info about the Filter settings.
var myGlow = new GlowFilter(myColor,myAlpha,myBlurX,myBlurY,myStrength,myQuality,myInner,myKnockout);
// Re-applies the filter to the object named myObject.
myObject.filters = [myGlow];
// Stops this function running when the blur setting goes under 30.
if (myBlurX < 20) {
delete this.onEnterFrame;
}
};
};
|
Why not try out webwasp's new community. Meet new people, find friends in your area: Webwasp Mates & Dates
•
6041 visitors to this page since
14 April 07 •
|
|
|
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.
|