效果如下
源文件下载
---------------下面是代码说明---------------------
for (var i = 1; i<=10; i++) {
//attach 5个mc,并有一个num属性放他们的序号
aa = attachMovie("all", "mc"+i, i, {num:i , _alpha:100-8*i});
aa.steep=0.4;
aa.steep2=0.5;//相当于"摩擦力系数"
aa.vx=0;
aa.vy=0;
aa.gotoAndStop(i);
aa.onEnterFrame = function() {
//mycolor=new Color();
mycolor=new Color(this);
mycolor.setRGB(random(0xffffff));
//第一个attach的mc(num==0的那个)跟随鼠标
if (this.num == 1) {
this.targetx = _root._xmouse;
this.targety = _root._ymouse
} else {
//否则跟随他的前一个(num-1)
this.targetx = eval("mc"+(this.num-1))._x;
this.targety = eval("mc"+(this.num-1))._y;
}
//缓冲~~~
this.vx=(this.targetx-this._x)*this.steep+this.vx*this.steep2;
this.vy=(this.targety-this._y)*this.steep+this.vy*this.steep2;
this._x+=this.vx;
this._y+=this.vy;
};
}
源文件下载
---------------下面是代码说明---------------------
for (var i = 1; i<=10; i++) {
//attach 5个mc,并有一个num属性放他们的序号
aa = attachMovie("all", "mc"+i, i, {num:i , _alpha:100-8*i});
aa.steep=0.4;
aa.steep2=0.5;//相当于"摩擦力系数"
aa.vx=0;
aa.vy=0;
aa.gotoAndStop(i);
aa.onEnterFrame = function() {
//mycolor=new Color();
mycolor=new Color(this);
mycolor.setRGB(random(0xffffff));
//第一个attach的mc(num==0的那个)跟随鼠标
if (this.num == 1) {
this.targetx = _root._xmouse;
this.targety = _root._ymouse
} else {
//否则跟随他的前一个(num-1)
this.targetx = eval("mc"+(this.num-1))._x;
this.targety = eval("mc"+(this.num-1))._y;
}
//缓冲~~~
this.vx=(this.targetx-this._x)*this.steep+this.vx*this.steep2;
this.vy=(this.targety-this._y)*this.steep+this.vy*this.steep2;
this._x+=this.vx;
this._y+=this.vy;
};
}
回复Comments
作者:
{commentrecontent}