那弹性的还真难做,试了一个下午没做出来.............你看看这样行不:
//图片总数:
total = 7;
//间距:
d = 25;
//图片宽:
w = 100;
//总长:
W = total*(w+d);
//图片变大变小的速度:
dScale = 10;
//在场景中加入图片:
for (i=1; i<=total; i++) {
this.attachMovie("pic", "pic"+i, i, {_x:i*(w+d)-W/2});
pic = this["pic"+i];
pic.gotoAndStop(i);
//鼠标放在图片上:
pic.onRollOver = function() {
this.onEnterFrame = function() {
//变大:
this._xscale = this._yscale += dScale;
//以该图片为基准调整距离:
pic0 = this;
distance(pic0);
//如果大到一定程度就停止变大:
if (this._xscale>200) {
this._xscale = this._yscale=200;
delete this.onEnterFrame;
pic0 = head;
}
};
};
//鼠标离开图片:
pic.onRollOut = function() {
this.onEnterFrame = function() {
//变小:
this._xscale = this._yscale -= dScale;
//以该图片为基准调整距离:
pic0 = this;
distance(pic0);
//如果小到一定程度就停止变小:
if (this._xscale<100) {
this._xscale = this._yscale=100;
delete this.onEnterFrame;
pic0 = head;
}
};
};
//用来建个类似双向链表的东东:
pic.prevPic = prevPic;
prevPic.nextPic = pic;
prevPic = pic;
}
//形成环链:
this.pic1.prevPic = this["pic"+total];
this["pic"+total].nextPic = this.pic1;
//
head = this.pic1;
tail = this["pic"+total];
//以链头为基准(用来调整距离):
pic0 = head;
//
function onEnterFrame() {
if (head._x<-W/2) {
head._x = tail._x+(tail._width+head._width)/2+d;
tail = head;
head = head.nextPic;
pic0 = head;
} else if (tail._x>W/2) {
tail._x = head._x-(tail._width+head._width)/2-d;
head = tail;
tail = tail.prevPic;
pic0 = head;
}
head._x += -_xmouse/20;
distance(pic0);
}
//--------------------------------------------------------------------------------------------
//以pic0为基准调整各幅画间距离的函数:
function distance(pic0) {
var pic = pic0;
while (pic != head) {
pic.prevPic._x = pic._x-(pic._width+pic.prevPic._width)/2-d;
pic = pic.prevPic;
}
pic = pic0;
while (pic != tail) {
pic.nextPic._x = pic._x+(pic._width+pic.nextPic._width)/2+d;
pic = pic.nextPic;
}
}