10、接下来将用简单的脚本来实现h1、h2 、h3的" 痉挛抽动"效果,点选主场景第一帧,添加如下代码:
_root.onenterframe = function() {
clear();
_root.linestyle(1.5, 0xcecece);
_root.moveto(_root.h1._x, _root.h1._y);
_root.l.neto(_root.h2._x, _root.h2._y);
_root.l.neto(_root.h3._x, _root.h3._y);
_root.l.neto(_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源文件下载
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器