用Flash制作神奇的弹性导航菜单(3)
作者: 来源: 添加时间:2006-5-23 7:40:00_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源文件下载
站内搜索