Flash as implementation uses the mouse to control the gradient fill

Source: Internet
Author: User
Tags define
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!



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.