flash as 2.0 实现图片切换代码
这里用as.20制作的一款图片轮换代码哦,不过这里要根mc.mov.loadMovie((((_root.root+"index_roll_")+i)+".jpg"));来实现加载目录的图片名称就OK了。
if ((_root.root == "") || (_root.root == undefined)) {
_root.root = "";
}
if ((_root.tm == "") || (_root.tm == undefined)) {
_root.tm = 100;
}
_root.tm = Number(_root.tm);
_root.sel = 1;
_root.sd = 10;
var i = 1;
var dateLocal = new Date();
var nowtime = String(dateLocal.getMilliseconds());
while (i<6) {
this["btn"+i].gotoAndStop(1);
this["btn"+i].num = i;
this["btn"+i].onRollOver = function() {
var _local1 = _root;
_local1.ss = false;
if (_local1.sel != this.num) {
_local1.mov.ttm = 0;
_local1.selp = _local1.sel;
_local1.sel = this.num;
_local1.mov["mov"+_local1.sel].swapDepths(_local1.sd++);
_local1.mov["mov"+_local1.sel]._x = 360;
}
};
this["btn"+i].onRollOut = function() {
_root.ss = true;
};
//this["btn"+i].onRelease = function() {
//getURL(("javascript:showIndexAD("+this.num)+");");
//};
mc = this.mov.createEmptyMovieClip("mov"+i, i);
mc.num = i;
mc._x = 360*(i-1);
mc.createEmptyMovieClip("mov", 1);
mc.mov.loadMovie((((_root.root+"index_roll_")+i)+".jpg"));
//mc.onRelease = function() {
//getURL(("javascript:showIndexAD("+this.num)+");");
//trace(this.num);
//};
mc.onRollOver = function() {
_root.ss = false;
};
mc.onRollOut = function() {
_root.ss = true;
};
i++;
}
_root.ss = true;
this.mov.ttm = 0;
this.mov.onEnterFrame = function() {
var _local2 = this;
var _local3 = _root;
if (_local3.ss == true) {
if ((_local2.ttm++)>_local3.tm) {
_local3.selp = _local3.sel;
if (_local3.sel == 5) {
_local3.sel = 1;
} else {
_local3.sel++;
}
_local2["mov"+_local3.sel].swapDepths(_local3.sd++);
_local2["mov"+_local3.sel]._x = 360;
_local2.ttm = 0;
}
}
_local2["mov"+_local3.sel]._x = _local2["mov"+_local3.sel]._x+(0.2*(-_local2["mov"+_local3.sel]._x));
_local2["mov"+_local3.selp]._x = _local2["mov"+_local3.selp]._x+(0.2*(-360-_local2["mov"+_local3.selp]._x));
var _local1 = 1;
while (_local1<6) {
if (_local3.sel == _local1) {
_local2._parent["btn"+_local1].nextFrame();
} else {
_local2._parent["btn"+_local1].prevFrame();
}
_local1++;
}
};
补充:flash教程,动画技术