我做的跟随效果
for (var i = 1; i<=50; i++) {
_root.attachMovie("dot", "dot"+i, i);
}
type1 = 1;
_root.dot1.onEnterFrame = function() {
if (_root.type1 == 1) {
this._xscale = 100;
this._yscale = 100;
this.stopDrag();
this.k = random(100);
if (this.k<20) {
this.newx = random(550);
this.newy = random(400);
}
this._x += (this.newx-this._x)/3;
this._y += (this.newy-this._y)/3;
this._rotation = Math.atan2(this.newy-this._y, this.newx-this._x)*(180/Math.PI);
}
if (_root.type1 == 2) {
this.startDrag(true);
}
if (_root.type1 == 3) {
this.stopDrag();
this._x += 5;
this._y += 20*Math.cos(this.ang += 0.2);
if (this._x>550) {
this._x = 0;
}
}
if (_root.type1 == 4) {
this._x += 50*Math.cos((this._rotation += 10)*(Math.PI/180));
this._y += 50*Math.sin((this._rotation += 10)*(Math.PI/180));
}
if (_root.type1 == 5) {
this._xscale = random(1000);
this._yscale = random(1000);
this.k = random(100);
if (this.k<20) {
this.newx = random(550);
this.newy = random(400);
}
this._x += (this.newx-this._x)/3;
this._y += (this.newy-this._y)/3;
this._rotation = Math.atan2(this.newy-this._y, this.newx-this._x)*(180/Math.PI);
}
};
_root.onMouseDown = function() {
_root.type1++;
if(_root.type1>5){
_root.type1=1;
}
};
for (var i = 2; i<=50; i++) {
eval("dot"+i).onEnterFrame = function() {
this._x += (eval("dot"+int(this._name.substr(3, 2)-1))._x-this._x)/3;
this._y += (eval("dot"+int(this._name.substr(3, 2)-1))._y-this._y)/3;
this._rotation = (eval("dot"+int(this._name.substr(3, 2)-1))._rotation-this._rotation)/2;
this._yscale += (eval("dot"+int(this._name.substr(3, 2)-1))._yscale-this._yscale)/3;
this._xscale += (eval("dot"+int(this._name.substr(3, 2)-1))._xscale-this._xscale)/3;
};
}
stop();