打印本文 打印本文 关闭窗口 关闭窗口
探讨三星Comdex展示的导航做法
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2752  更新时间:2003/7/5  文章录入:mintao  责任编辑:mintao

下面是其核心部分的as:
代码拷贝框

[Ctrl+A 全部选择 然后拷贝]

大家来分析一下思路。

源文件

所有代码集中在一个帧里
下面是代码及简单注释:

//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;

  }
  else{
      this.posYStep = this.posYStep * flex + (this.goalYPos - this._y) * drag;
      this._y =this._y + this.posYStep;
 
      this.posXStep = this.posXStep * flex + (this.goalXPos - this._x) * drag;
      this._x = this._x + this.posXStep;
  }
 }
 
 theObj.onMouseMove=function(){
  var dx=(_root._xmouse-this._x);
  var dy=(_root._ymouse-this._y);
  var d=Math.sqrt(dx*dx+dy*dy);
  if(d<30 ) {
   this.draging=true;
  }else{
   this.draging=false;
&nbs

[1] [2]  下一页

打印本文 打印本文 关闭窗口 关闭窗口