| 网站首页 | 模板 | 资料 | 源码 | 工具 | 开发 | 设计 | 安全 | 项目 | 网络 | 图片 | 系统 | 数据库 | 博客 | 会员中心 | 小说 | 
MYFTP 精品资料下载
网络学院
学习资料
源码模版
您现在的位置: 精品下载 >> 网络 >> 电脑课堂 >> 网络正文 用户登录 新用户注册
探讨三星Comdex展示的导航做法            【字体:
探讨三星Comdex展示的导航做法
作者:佚名    网络来源:不详    点击数:    更新时间:2007-12-28

下面是其核心部分的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;
   for(var i=0;i<BallsNum;i++){
   var theObj= eval("_root.pit"+i);
    theObj.goalYPos=theObj.orgYpos;
    theObj.goalXPos=theObj.orgXpos;
   }
  }
 }
}

////////////////////////////////////////////////////////////////
_root.createEmptyMovieClip("line",1); // 画线

this["line"].onEnterFrame=function (){
 this.clear();
 this.lineStyle( 1, 0xffffff, 100 );
 this.moveTo( _root.pit0._x, _root.pit0._y);
 for(var i=1;i<BallsNum;i++){
 var theobj=eval("_root.pit"+i);
 this.lineTo(theobj._x,theobj._y);
 }
 this.lineTo(_root.pit0._x, _root.pit0._y);
}

代码还未经优化,未考虑异常情况处理,仅供大家学习研究。

基本上,我做的这个没有参考三星的原程序。仅仅是效果上的一种摹仿。
大家可以探讨一下其他方法。

相关讨论:

http://www.blueidea.com/bbs/newsdetail.asp?id=785785

网络录入:chqnet    责任编辑:chqnet 
  • 上一个网络:

  • 下一个网络:
  • 最新热点 最新推荐 相关网络
    三星网络相册 时尚无比精彩
    ADSL宽带接入网及其网络优化…
    局域网中IP地址冲突的探讨
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)