//DARKVN版權(quán)所有請(qǐng)勿作商業(yè)用途 //本程序需flash 6.0支持。 var BallsNum=7; // 設(shè)定節(jié)點(diǎn)個(gè)數(shù) var centerX=300;//設(shè)定節(jié)點(diǎn)中心位置 var centerY=200; var cRadius=120; var drag=0.2;//震動(dòng)參數(shù) var flex=0.7;//震動(dòng)參數(shù) for (var i=0;i<BallsNum;i++){ //生成節(jié)點(diǎn) _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); //帶限制的隨機(jī)節(jié)點(diǎn)位置 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;