三星弹性导航菜单再探详解
作者 佚名技术
来源 服务器技术
浏览
发布时间 2012-07-10
; this.vx += (tarx-this._x)*k; this.vy += (tary-this._y)*k; this.vx = this.vx*damp; this.vy = this.vy*damp; var xdis = this._x-_root["a"+(namenumber-1)]._x; var ydis = this._y-_root["a"+(namenumber-1)]._y; var ang = Math.atan2(ydis, xdis); var tarx = _root["a"+(namenumber-1)]._x+Math.cos(ang)*90; var tary = _root["a"+(namenumber-1)]._y+Math.sin(ang)*90; this.vx += (tarx-this._x)*k; this.vy += (tary-this._y)*k; this.vx = this.vx*damp; this.vy = this.vy*damp; this._x += this.vx; this._y += this.vy; //making the mc which besides to me follow me! } else if (namenumber == 5) {//5的情况类似了 var xdis = this._x-_root.a4._x; var ydis = this._y-_root.a4._y; var ang = Math.atan2(ydis, xdis); var tarx = _root.a4._x+Math.cos(ang)*90; var tary = _root.a4._y+Math.sin(ang)*90; this.vx += (tarx-this._x)*k; this.vy += (tary-this._y)*k; this.vx = this.vx*damp; this.vy = this.vy*damp; var xdis = this._x-_root.a0._x; var ydis = this._y-_root.a0._y; var ang = Math.atan2(ydis, xdis); var tarx = _root.a0._x+Math.cos(ang)*90; var tary = _root.a0._y+Math.sin(ang)*90; this.vx += (tarx-this._x)*k; this.vy += (tary-this._y)*k; this.vx = this.vx*damp; this.vy = this.vy*damp; this._x += this.vx; this._y += this.vy; } } } //下面的代码简单了,我想你看的明白了,我以前的教程中有这类的用法 function rando(x, y) { six = Math.random()*30+1+(x-15); siy = Math.random()*30+1+(y-15); } k = .4; damp = .7; numFeet = 5; forbid = 0; for (i=0; i<=5; i++) { _root.li.attachMovie("b", "a"+i, -i); _root.li["a"+i]._x = _root["a"+i]._x; _root.li["a"+i]._y = _root["a"+i]._y; _root["a"+i].oldx = _root["a"+i]._x; _root["a"+i].oldy = _root["a"+i]._y; _root["a"+i].pres = false; } //------------------------------------ for (i=0; i<=5; i++) { _root["a"+i].onRollOver = showme; _root["a"+i].onPress = doDrag; _root["a"+i].onRelease = noDrag; _root["a"+i].onReleaseOutside = noDrag; _root["a"+i].onEnterFrame = makemove; _root["a"+i].follow = 0; } _root.li.onEnterFrame = function() { _root.li.clear(); _root.li.lineStyle(1, 0, 50); i = 0; while (i<=numFeet) { if (i != 5) { _root.li.moveTo(_root["a"+i]._x, _root["a"+i]._y); _root.li.lineTo(_root["a"+(i+1)]._x, _root["a"+(i+1)]._y); } else if (i == 5) { _root.li.moveTo(_root.a5._x, _root.a5._y); _root.li.lineTo(_root.a0._x, _root.a0._y); } i++; } }; 呵呵,还没完,因为我吸附效果不是通过直接距离实现的,偷懒用了一个透明的 mc通过hitTest来判断上面的代码你如果仔细看了一定发现 每个按钮下我都 attachMovieClip()就是这样 在这上面我加了下面的代码: 看了这么大一堆代码别晕哦,其实我就是想让当鼠标靠近按钮的时候,被吸引了以后就像按下按钮被拖动的时候效果一样跟着鼠标走了,由于与前面联系的变量很多,要解决的逻辑问题也很多,你完全可以按照你的思路去,同样一个效果实现的 手段绝对不止一种 onClipEvent (load) { this.oldx = _parent._x; this.oldy = _parent._y; } onClipEvent (enterFrame) { this.dx = (_parent._x-this.oldx)*(_parent._x-this.oldx)+(_parent._y-this.oldy)*(_parent._y-this.oldy); if (_root.forbid == 0 || _root.forbidname == _parent._name) { if (_parent.hitTest(_root._xmouse, _root._ymouse, true)) { _root.forbid = 1; |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
HTTP/1.1 401 Access Denied