看效果:
代码如下:
var old:Number = 1;
//记录上张显示的图片
var oldGo:Boolean;
var oldpos:Number = 700;
var picNum:Number = 9;
//anliPath是用于加载外部图片的路径
//var anliPath:String = "works/1-";
for (i=1; i<=picNum; i++) {
btn_mc.attachMovie("btn", "btn"+i, i);
btn_mc["btn"+i]._y = 28*(i-1);
btn_mc["btn"+i]._x = 10;
btn_mc["btn"+i].no = i;
btn_mc["btn"+i].page.text = i;
btn_mc["btn"+i].btn.useHandCursor = false;
btn_mc["btn"+i].btn.onRelease = function() {
oldpos = oldpos*(-1);
motion(oldpos, old);
motion(0, this._parent.no);
old = this._parent.no;
};
this.pic.createEmptyMovieClip("mc"+i, picNum-i);
this.pic["mc"+i].no = i-1;
if (i == 1) {
this.pic["mc"+i]._x = 0;
} else {
this.pic["mc"+i]._x = -500;
}
//*****************attachMovie内部图片的代码****************
this.pic["mc"+i].attachMovie("m"+i, "m"+i, 100-i);
//*********************************加载外部图片的代码*******************
//图片加载进度条的设置
//
//myLoader = new MovieClipLoader();
//myListener = new Object();
//myListener.onLoadProgress = function(loadTargetMC, loadedBytes, totalBytes) {
//aa = (loadedBytes/totalBytes)*100;
//txt.text = "己加载:"+int(aa)+"%";
//};
//myListener.onLoadStart = function(loadTargetMC) {
//txt._visible = true;
//this.pic["mc"+i].stop();
//};
//myListener.onLoadComplete = function(loadTargetMC) {
//this.pic["mc"+i].play();
//txt._visible = false;
//if (i == 1) {
//motion(1200, 1);
//}
//};
//myLoader.addListener(myListener);
//myLoader.loadClip(anliPath+i+".gif", this.pic["mc"+i]);
//***************加载外部图片的代码结束**************
}
function motion(targetX:Number, no:Number) {
pic["mc"+no].onEnterFrame = function() {
this._x += (targetX-this._x)*0.3;
if (Math.abs(targetX-this._x)<=0.3) {
this._x = targetX;
delete this.onEnterFrame;
}
};
}
stop();
源文件下载:
图片效果系列之四.rar