闪吧用了我的第二篇教材了

      Flash学习 2006-8-1 22:32
用MovieClipLoader连续加载外部图片并进行控制
作者:yuheduo 类型:闪吧BBS 来源:闪吧  
也不记得在那个高手的blog上看到过。学习过,这里有人问起那就拿来用一用了,(整理出来)
代码如下:

var selectedmc;
var id=1;
var Num=13;
var myML:MovieClipLoader=new MovieClipLoader();
var myL:Object=new Object();
myL.onLoadComplete=function(target:MovieClip){
if(id==1) target._visible=true;
else target._visible=false;
_root["imgBtn"+id+"_btn"].label=id;
trace(_root["imgBtn"+id+"_btn"]);
id++;
if(id<Num){
loadpic(id);
}else{
//for(var i=;i<Num,i++){

//}
}
}
myL.onLoadInit=function(target:MovieClip){
target._width=400;
target._height=300;
target._x=(540-400)/2;
target._y=30;
}
myL.onLoadProgress=function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number){
_root["imgBtn"+id+"_btn"].label=Math.round(100*bytesLoaded/bytesTotal)+"%";
}
myML.addListener(myL);
function loadpic(n){
var name_btn="imgBtn"+n+"_btn";
var name_mc="imgMc"+n+"_mc";
name_btn=_root.attachMovie("Button",name_btn,_root.getNextHighestDepth());
name_mc=_root.createEmptyMovieClip(name_mc,_root.getNextHighestDepth());
name_mc.id=n;
name_btn.setSize(35,22);
name_btn._x=10+(n-1)*40;
name_btn._y=360;
name_btn.toimg=name_mc;
name_btn.onPress=function(){
selectedmc._visible=false;
selectedmc=this.toimg;
selectedmc._visible=true;
}
var n2=n;
if(Number(n2)<10)n2="0"+n2;
//myML.loadClip("http://www.pconline.com.cn/pcedu/photo/0604/pic/060428vistawwp0"+n+"-b.jpg",name_mc);
myML.loadClip("http://www.pconline.com.cn/pcedu/photo/0604/pic/060428fruit"+n2+".jpg",name_mc);
}
btn.label="导入";
btn.onPress=function(){
loadpic(id);
}
责任编辑:uufeng 时间:2006年5月8日
标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commenttime}{commentauthor}

{CommentUrl}
{commentcontent}