实现将图片加载到元件中的功能
要加载的文件
loadfile = "http://www.deskcar.com/desktop/fengjing/2004222154314/56.JPG";
//要加载到的元件
loadmc = _root.mc1;
var my_mcl = new MovieClipLoader();
myListener = new Object();
myListener.onLoadProgress = function(target_mc, loadedBytes, totalBytes) {
loaded = loadedBytes;
loadtotal = totalBytes;
loadds = int(loaded/loadtotal*100);
//动态文本显示下载百分比
loadtxt = int(loaded/1024)+" K / "+int(loadtotal/1024)+" K "+loadds+"%";
//设置进度条
_root.loadbar.gotoAndStop(loadds);
};
myListener.onLoadInit = function(target_mc) {
//这里获取加载的文件的尺寸
//开始设置大小
if (loadds == 100) {
loadmc._alpha = 0;
loadmc.onEnterFrame = function (){
this._alpha+=5;
if(this._alpha>=100){
detele this.onEnterFrame;}
}
target_mc.removeListener(myListener);
_root.mymc._width = 214;
_root.mymc._height = 158;
}
};
myListener.onLoadError = function(target_mc, errorCode) {
if (errorCode == "URLNotFound" || errorCode == "LoadNeverCompleted") {
//加载出错时候处理
loadtxt = "文件不存在!";
}
};
my_mcl.addListener(myListener);
my_mcl.loadClip(loadfile, loadmc);
stop();
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |