统计在线人数...

用Flash制作神奇的弹性导航菜单(3)

[ 来源:互联网 | 作者:佚名 | 时间:2006-9-1 下午 11:57:13 | 浏览:统计中... ]


10、接下来将用简单的脚本来实现h1、h2 、h3的" 痉挛抽动"效果,点选主场景第一帧,添加如下代码:

  _root.onEnterFrame = function() {
    clear();
    _root.lineStyle(1.5, 0xcecece);
    _root.moveTo(_root.h1._x, _root.h1._y);
    _root.lineTo(_root.h2._x, _root.h2._y);
    _root.lineTo(_root.h3._x, _root.h3._y);
    _root.lineTo(_root.h1._x, _root.h1._y);
    _root.endFill();
  }

  后面加上如下脚本:

  setInterval(myball1, 6000);
  function myball1() {
    if (_root.h1.hitTest(_root._xmouse, _root._ymouse, false)) {
      _root.h1._x = _root._xmouse;
      _root.h1._y = _root._ymouse;
    } else {
      _root.h1._x += 70-random(150);  ||设置MC的随机坐标
      _root.h1._y += 50-random(150);
    }
  }
  setInterval(myball2, 5000);
  function myball2() {
    if (_root.h2.hitTest(_root._xmouse, _root._ymouse, false)) {
      _root.h2._x = _root._xmouse;
      _root.h2._y = _root._ymouse;
    } else {
      _root.h2._x += 70-random(140);
      _root.h2._y += 60-random(150);
    }
  }
  setInterval(myball3, 4000);
  function myball3() {
    if (_root.h3.hitTest(_root._xmouse, _root._ymouse, false)) {
      _root.h3._x = _root._xmouse;
      _root.h3._y= _root._ymouse;
    } else {
      _root.h3._x += 70-random(80);
      _root.h3._y += 50-random(90);
    }
  }

  其中if (……)这个判断是为了消除鼠标drag的时候由于自定义函数的反复调用,MC坐标发生变化后出现的一个问题。至此,就实现了利用setInterval隔一段时间就反复调用自定义函数使MC的坐标随机发生变化,偏离原来的坐标, 从而实现MC的" 痉挛抽动 "效果。

  赶快把这个神奇的导航菜单加到你的网站吧,一定可以使你的主页在浩瀚的网络中脱颖而出!fla源文件下载


共有0人参与评价,平均得分:0分
评论内容只代表网友观点,与本站立场无关! 查看完整内容
   

当前在线人数
QQ:748838 MSN:allen_xia#msn.com E-mail:allenxia666#126.com QQ群:站长联盟北方区-北京(28200145) 站长联盟南方区-上海(67713522)