同步加载多个外部swf代码整理
类别: Flash教程
这个我记得是很早学来的,所以今天又整理了下放出来,方便大家查询使用: )
function manyLoadMovie(num, x, y, xscal, yscal, dis) {
for (var i = 0; i<num; i++) {
var Temp = createEmptyMovieClip("temp"+i, i);
var L = createEmptyMovieClip("load"+i, i+num);
Temp.t = i;
L.loadMovie(i+".swf");
L._xscale = xscal;
L._yscale = yscal;
L._x = x+i*dis;
L._y = y;
T = createTextField("txt"+i, i+10000, L._x, L._y, 100, 100);
Temp.onEnterFrame = function() {
var a = this._parent["load"+this.t].getBytesLoaded();
var b = this._parent["load"+this.t].getBytesTotal();
this._parent["txt"+this.t].text = int(a*100/b)+"%";
if (a>=b and a>10) {
this._parent["txt"+this.t].removeTextField();
this.removeMovieClip();
}
};
}
}
manyLoadMovie(4, 100, 100, 50, 50, 50);
for (var i = 0; i<num; i++) {
var Temp = createEmptyMovieClip("temp"+i, i);
var L = createEmptyMovieClip("load"+i, i+num);
Temp.t = i;
L.loadMovie(i+".swf");
L._xscale = xscal;
L._yscale = yscal;
L._x = x+i*dis;
L._y = y;
T = createTextField("txt"+i, i+10000, L._x, L._y, 100, 100);
Temp.onEnterFrame = function() {
var a = this._parent["load"+this.t].getBytesLoaded();
var b = this._parent["load"+this.t].getBytesTotal();
this._parent["txt"+this.t].text = int(a*100/b)+"%";
if (a>=b and a>10) {
this._parent["txt"+this.t].removeTextField();
this.removeMovieClip();
}
};
}
}
manyLoadMovie(4, 100, 100, 50, 50, 50);
//参数分别是文件数量,起点x,起点y,宽度比例,高度比例,排列间距.
//注意外部文件分别为0.swf,1.swf,2.swf.........递增的,其实稍微改下,加载图片也一样
以下是文件打包:
[下载源文件](说明:)
//由于这个功能运用在很多网站上,所以觉得还是蛮有用的,这里只是显示百分比,测试的时候ctrl+enter两次就行,外部文件大些明显些,至于进度条的也很容易,大家自己弄吧,我不行了,感冒太严重,流鼻涕中....
- 上一篇: Flash视觉特效:科技之光
- 下一篇: Flash中实现场景的跳转的五种方法
-= 资 源 教 程 =-
文 章 搜 索