繁體
|
簡體
Sclub交友聊天~加入聊天室當版主
(檢舉)
分享
新浪微博
QQ空间
人人网
腾讯微博
Facebook
Google+
Plurk
Twitter
Line
标题:
[AS2源码]
[AS2]阴影的鼠标交互
[打印本页]
作者:
网雨霏霏
时间:
2019-1-9 10:34
标题:
[AS2]阴影的鼠标交互
是否原创:否
转自何处:
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
作者:
蘑菇头
时间:
2019-1-13 20:03
感谢分享......
欢迎光临 flash之路-flash技术交流 (http://flashroad.dhlog.com/)
Powered by Discuz! 7.2