Gradient | control | mouse
Using the action script of Flash 8 to control the gradient fill effect of the pattern with the mouse
First look at the effect:
Click here to download the source file
Press Ctrl+j to modify document properties:
Then press F9 to open the action panel and enter the following statement:
Import Flash.filters.GradientBevelFilter; Filters that refer to Flash: Gradientbevelfilter.
var shapeclip:movieclip = This.createemptymovieclip ("SHAPE_MC", 1); Create a movie clip.
With (Shapeclip) {
Beginfill (0xff0000, 100);
MoveTo (0, 0);
LineTo (200, 0);
LineTo (200, 200);
LineTo (0, 200);
LineTo (0, 0);
Endfill ();
//define the size of the movie clip Shape_mc.
shapeclip._x = (stage.width-shapeclip._width)/2;
Shapeclip._y = (stage.height-shapeclip._height)/2;//The interface to create a movie clip
var colors:array = new Array (0xFFFFFF, 0xCCCCCC, 0x000000); Set color
var alphas:array = new Array (1, 0, 1); Set Alpha
var ratios:array = new Array (0, 128, 255);//Set properties
var gradientbevel:gradientbevelfilter = new Gradientbevelfilter (ten, colors, Alphas, ratios, 4, 4, 5, 3); Set filter, alpha, and size
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);//define mouse function
Finally press the Ctrl+enter test!