免費論壇 繁體 | 簡體
Sclub交友聊天~加入聊天室當版主
分享

[AS2]阴影的鼠标交互

本文来自:★flash之路-flash技术交流★ 转帖请注明出处! 作者:网雨霏霏 您是第3664个浏览者

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
flashroad友情提示:
“点评”不是“回帖”!
是否原创:否
转自何处:http://www.senocular.com/flash/source/?entry=760
AS版本:AS2
前期准备:需要在舞台上放置一个影片剪辑,并设定实例名为f_mc
效果预览:

[flash]http://www.senocular.com/flash/files/mousebevelandshadow.swf[/flash]
移动鼠标,可以看见效果

AS代码:
  1. Stage.scaleMode = 'noScale';

  2. // import flash filters
  3. import flash.filters.*;

  4. // define a maximum distance value for the bevel
  5. var maxbeveldistance:Number = 5;

  6. // create the bevel filter
  7. var bevel:BevelFilter = new BevelFilter();
  8. // give the bevel a strength of .6
  9. bevel.strength = .6;

  10. // create a dropshadow filter
  11. var dropshadow:DropShadowFilter = new DropShadowFilter();
  12. // apply dropshadow filter settings
  13. dropshadow.color = 0x000000;
  14. dropshadow.alpha = .75;
  15. dropshadow.blurX = 10;
  16. dropshadow.blurY = 10;

  17. // update the filters when the mouse is moved
  18. onMouseMove = function(){

  19. // find the difference of location of the
  20. // mouse from the center of f_mc
  21. var dx = _xmouse - f_mc._x;
  22. var dy = _ymouse - f_mc._y;

  23. // determine a distance
  24. var distance = Math.sqrt(dx*dx + dy*dy);
  25. // determins an angle (in radians)
  26. var angle = Math.atan2(dy, dx);


  27. // apply distance and angle to bevel filter
  28. // do not let bevel.distance go above maxbeveldistance
  29. // dividing distance by 50 keeps it reasonable
  30. bevel.distance = Math.min(maxbeveldistance, distance/50);
  31. bevel.angle = 180 + angle * 180/Math.PI; // convert and rotate 180 degress

  32. // apply distance and angle to dropshadow filter
  33. // dividing distance by 20 keeps it reasonable
  34. // note that this is slightly different than the
  35. // divisor used for the bevel filter
  36. dropshadow.distance = distance/20;
  37. dropshadow.angle = 180 + angle * 180/Math.PI; // convert and rotate 180 degress

  38. // add the filters to the f_mc movie clip, bevel first
  39. f_mc.filters = [bevel, dropshadow];
  40. }

  41. // initiate
  42. onMouseMove();
复制
fla文件下载【flash8格式】
http://www.senocular.com/flash/files/mousebevelandshadow.fla
您所在的用户组只能看到部分内容.
如查看全部内容, 请先登录或者注册.

获得 小赌神卡 一张

卡片说明:网雨霏霏照顾了失踪的小狗,主人付出了8金钱以作感谢

卡片效果:+8

友情提示:单击下列任意一个表情,即可瞬间自动回复本帖!

好贴......
郁闷......
开心......
擦汗......
鄙视......
狂怒
谢谢
爱你呦
拜托了
嗯嗯
OMG
求关注
伤心......
无奈.....
无奈.....
无奈.....
无奈.....
无奈.....
哈哈哈
NO
OK
what
我来了

最近访问本帖者列表:

迷彩不流泪
访问时间:2020-02-18 23:53
许森匡
访问时间:2019-02-07 09:58
flashroad
访问时间:2019-01-16 21:09
蘑菇头
访问时间:2019-01-13 20:02
虚心
访问时间:2019-01-13 11:18
网雨霏霏
访问时间:2019-01-09 10:34

打赏

取消

感谢您的支持,我会继续努力的!

扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

Powered by 爱秀代码,分享从这里开始,精彩与您同在

点评
B Color Smilies

您还可以输入:个字符
X

X

感谢分享......
您所在的用户组只能看到部分内容.
如查看全部内容, 请先登录或者注册.

获得 大福神卡 一张

卡片说明:蘑菇头帮助迷路的小朋友找到家长,家长为表达谢意,付出了4威望

卡片效果:+4

点评
B Color Smilies

您还可以输入:个字符
X

X

TOP

 

B Color Image Link Quote Code Smilies
高级模式 | 发新话题

您需要登录后才可以回帖 登录|立即注册

快速
返回顶部
返回首页