See this tutorial and learn how to create gradient effect in flash 8 using the Action Script and mouse. Below is the live Flash example of what you are going to create in this tutorial.
Step 1
Create a new flash document, press Ctrl+R on the keyboard (Document Properties) and set Width and Height to 200px.
Step 2
Select the first frame, open the Action Script Pannel (F9), and write this:
import flash.filters.GradientBevelFilter;
var shapeClip:MovieClip = this.createEmptyMovieClip("shape_mc", 1);
shape_mc
with (shapeClip) {
beginFill(0xFF0000, 100);
moveTo(0, 0);
lineTo(200, 0);
lineTo(200, 200);
lineTo(0, 200);
lineTo(0, 0);
endFill();
}
shapeClip._x = (Stage.width - shapeClip._width) / 2;
shapeClip._y = (Stage.height - shapeClip._height) / 2;
var colors:Array = new Array(0xFFFFFF, 0xCCCCCC, 0x000000);
var alphas:Array = new Array(1, 0, 1);
var ratios:Array = new Array(0, 128, 255);
var gradientBevel:GradientBevelFilter = new GradientBevelFilter(10, 45, colors, alphas, ratios, 4, 4, 5, 3);
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function() {
gradientBevel.strength++;
shapeClip.filters = [gradientBevel];
};
mouseListener.onMouseMove = function() {
gradientBevel.blurX = (_xmouse / Stage.width) * 255;
gradientBevel.blurY = (_ymouse / Stage.height) * 255;
shapeClip.filters = [gradientBevel];
};
Mouse.addListener(mouseListener);
Step 3
Short script explanation:
This script:
import flash.filters.GradientBevelFilter;
includes the filters,
This script:
var shapeClip:MovieClip = this.createEmptyMovieClip("shape_mc", 1);
create a Movie Clip with name,
This script:
shape_mc
with (shapeClip) {
beginFill(0xFF0000, 100);
moveTo(0, 0);
lineTo(200, 0);
lineTo(200, 200);
lineTo(0, 200);
lineTo(0, 0);
endFill();
}
determines the size of movie,
This script:
shapeClip._x = (Stage.width - shapeClip._width) / 2;
shapeClip._y = (Stage.height - shapeClip._height) / 2;
creates the forms,
This script:
var colors:Array = new Array(0xFFFFFF, 0xCCCCCC, 0x000000);
ste the colors,
This script:
var alphas:Array = new Array(1, 0, 1);
set the alpha,
This sript:
var ratios:Array = new Array(0, 128, 255);
set the proportions,
This script:
var gradientBevel:GradientBevelFilter = new GradientBevelFilter(10, 45, colors, alphas, ratios, 4, 4, 5, 3);
comprises gradient bevel filter and set the alpha and sizes.
This script:
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function() {
gradientBevel.strength++;
shapeClip.filters = [gradientBevel];
};
mouseListener.onMouseMove = function()
determines the function for mouse following.
We're done!
Bye!
Download source file (.fla)