Filter effect that follows mouse changes

Source: Internet
Author: User

New Flash 8 instance teaching material: filter effect changed with the mouse

This example uses Flash 8 for production and release. Please update your ie browser plug-in to Flash 8 for viewing ~
[Upload = swf] UploadFile/2005-12/20051231183349122. sw

The following methods are used to create an ECS instance:
1. Create a MC, drag it to the stage, and change the instance name to myMC.
2. Add the following code:
Import flash. filters. *; // load filter class
// Defines the offset distance of the initial oblique filter.
Var maxbeveldistance: Number = 5;
// Create an angle filter.
Var bevel: BevelFilter = new BevelFilter ();
// Defines the intensity of the initial oblique filter.
Bevel. strength =. 6;
// Create a projection filter.
Var dropshadowropShadowFilter = new DropShadowFilter ();
// Initialize the projection filter.
Dropshadow. color = 0x000000;
Dropshadow. alpha =. 75;
Dropshadow. blurX = 10;
Dropshadow. blurY = 10;
// Update filter data following mouse changes
OnMouseMove = function (){

// Calculate the distance between the current mouse and mc
Var dx = _ xmouse-myMC. _ x;
Var dy = _ ymouse-myMC. _ y;

// Calculate the distance
Var distance = Math. sqrt (dx * dx + dy * dy );
// Calculate the offset
Var angle = Math. atan2 (dy, dx );


// Apply the offset distance and angle of oblique light.
Bevel. distance = Math. min (maxbeveldistance, distance/50 );
Bevel. angle = 180 + angle * 180/Math. PI; // convert and rotate 180 degress


// Apply the projection offset distance and angle
Dropshadow. distance = distance/20;
Dropshadow. angle = 180 + angle * 180/Math. PI; // convert and rotate 180 degress

// Add a filter to mc ~
MyMC. filters = [bevel, dropshadow];
}
// Initialization
OnMouseMove ();

Because there are many filters, you can only use these filters or use different filters ~

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.