是否原创:否
转自何处:
http://www.senocular.com/flash/source/?entry=760
AS版本:AS2
前期准备:需要在舞台上放置一个影片剪辑,并设定实例名为
f_mc
效果预览:
[flash]http://www.senocular.com/flash/files/mousebevelandshadow.swf[/flash]
移动鼠标,可以看见效果
AS代码:
- Stage.scaleMode = 'noScale';
- // import flash filters
- import flash.filters.*;
- // define a maximum distance value for the bevel
- var maxbeveldistance:Number = 5;
- // create the bevel filter
- var bevel:BevelFilter = new BevelFilter();
- // give the bevel a strength of .6
- bevel.strength = .6;
- // create a dropshadow filter
- var dropshadow:DropShadowFilter = new DropShadowFilter();
- // apply dropshadow filter settings
- dropshadow.color = 0x000000;
- dropshadow.alpha = .75;
- dropshadow.blurX = 10;
- dropshadow.blurY = 10;
- // update the filters when the mouse is moved
- onMouseMove = function(){
- // find the difference of location of the
- // mouse from the center of f_mc
- var dx = _xmouse - f_mc._x;
- var dy = _ymouse - f_mc._y;
- // determine a distance
- var distance = Math.sqrt(dx*dx + dy*dy);
- // determins an angle (in radians)
- var angle = Math.atan2(dy, dx);
- // apply distance and angle to bevel filter
- // do not let bevel.distance go above maxbeveldistance
- // dividing distance by 50 keeps it reasonable
- bevel.distance = Math.min(maxbeveldistance, distance/50);
- bevel.angle = 180 + angle * 180/Math.PI; // convert and rotate 180 degress
- // apply distance and angle to dropshadow filter
- // dividing distance by 20 keeps it reasonable
- // note that this is slightly different than the
- // divisor used for the bevel filter
- dropshadow.distance = distance/20;
- dropshadow.angle = 180 + angle * 180/Math.PI; // convert and rotate 180 degress
- // add the filters to the f_mc movie clip, bevel first
- f_mc.filters = [bevel, dropshadow];
- }
- // initiate
- onMouseMove();
复制fla文件下载【flash8格式】
http://www.senocular.com/flash/files/mousebevelandshadow.fla