//DARKVN版权所有请勿作商业用途 //本程序需flash 6.0支持。 var BallsNum=7; // 设定节点个数 var centerX=300;//设定节点中心位置 var centerY=200; var cRadius=120; var drag=0.2;//震动参数 var flex=0.7;//震动参数 for (var i=0;i<BallsNum;i++){ //生成节点 _root.attachMovie("pit","pit"+i,100+i); var theObj= eval("_root.pit"+i); theObj.posXStep = 0; theObj.posYStep = 0; theObj._x = centerX+Math.floor(cRadius + Math.random() * 50 - 25) * Math.cos(6.283185 * (i + Math.random()) / BallsNum); //带限制的随机节点位置 theObj._y = centerY+Math.floor(cRadius + Math.random() * 50 - 25) * Math.sin(6.283185 * (i + Math.random()) / BallsNum); theObj.goalXPos = theObj._x; theObj.goalYPos = theObj._y; theObj.orgXpos = theObj._x; theObj.orgYpos = theObj._y; theObj.index=i; theObj.draging=false; theObj.gotoAndPlay(random(60)); theObj.text="MENUITEM"+ (i+1);
theObj.onEnterFrame =function (){ if(this.draging){ this._x=_root._xmouse; this._y=_root._ymouse; theNext=eval("_root.pit"+((this.index==(BallsNum-1))? 0 : this.index+1)); var dy=this._y-theNext._y; var dx=this._x-theNext._x; var d=Math.sqrt(dx*dx+dy*dy); var arc=Math.atan2(dy,dx); theNext.goalYPos=theNext.orgYpos+Math.sin(arc)*d*0.2; theNext.goalXpos=theNext.orgXpos+Math.cos(arc)*d*0.2; thePrev=eval("_root.pit"+((this.index==(0))? BallsNum-1 : this.index-1)); var dy=this._y-thePrev._y; var dx=this._x-thePrev._x; var d=Math.sqrt(dx*dx+dy*dy); var arc=Math.atan2(dy,dx); thePrev.goalYPos=thePrev.orgYpos+Math.sin(arc)*d*0.2; thePrev.goalXpos=thePrev.orgXpos+Math.cos(arc)*d*0.2;