这是我在一个连续加载图像的图库中使用的代码。当您必须打开不同的影像专辑并且必须消除动画片段中以前加载的所有孩子时,我的问题才会出现。当我加载新相册时,我使用了您在此发布的代码:AS3 How to remove previous loaders,但问题在于,有时用户在所有图片出现之前都会离开相册页面,因此当他们点击新相册打开相册时,新图片会被放置在其他位置导致装载机已经启动。我试图关闭()加载程序,但它似乎不工作。如果你能帮我一把,我会感激不尽。先谢谢了。在这里,您可以看到工作现场www.barbarabritvin.com(看什么IM交谈abouy你必须点击专辑,之前所有图片加载离开,并开辟一个又一个。来自阿根廷加油!由于无法关闭()加载程序,因此无法删除库中的所有加载的子项!
getImage(dataList[0].file)
function getImage(href:String):void {
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageReady);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress);
loader.x=xCounter
loader.load(new URLRequest(href));
}
function imageReady(e:Event):void {
var bitmap:Bitmap=e.target.content;
if (bitmap!=null) {
bitmap.smoothing=true;
}
displayLarge2.thumb_loader.thumbHolderInside.addChildAt(e.target.loader,0)
yaCargo=true
trace("NUMCHILDREN"+displayLarge2.thumb_loader.thumbHolderInside.numChildren)
collection.push(e.target.content);
xCounter=xCounter+e.target.loader.width+3
imagecounter++;
if(imagecounter < dataList.length() && loadingPics==true) {
getImage(dataList[imagecounter].file);
}
}
function clearThumbs():void
{
while(displayLarge2.thumb_loader.thumbHolderInside.numChildren > 0)
{
//Remove the first child until there are none.
displayLarge2.thumb_loader.thumbHolderInside.removeChildAt(0);
}
}
displayLarge2.close.addEventListener(MouseEvent.CLICK, closeAlbum)
function closeAlbum(e:MouseEvent):void{
displayLarge2.thumb_loader.thumbHolderInside.enabled=false
loadingPics=false
while(displayLarge2.thumb_loader.thumbHolderInside.numChildren>0)
{
displayLarge2.thumb_loader.thumbHolderInside.removeChildAt(0)
}
trace("NUMCHILDREN"+displayLarge2.thumb_loader.thumbHolderInside.numChildren)
imagecounter=0
xCounter=0
displayLarge2.enabled=false
displayLarge2.mouseChildren=false
var scrollerTween=TweenManager.create(displayLarge2,"alpha",Regular.easeIn,1,0,0.5,true);
scrollerTween.addEventListener(TweenEvent.MOTION_FINISH, doNextTween)
function doNextTween(e:TweenEvent):void{
sectionThumbs.enabled=true
sectionThumbs.mouseChildren=true
displayLarge2.visible=false
var thumbsTween=TweenManager.create(sectionThumbs,"alpha",Regular.easeIn,0,1,0.5,true);
scrollerTween.removeEventListener(TweenEvent.MOTION_FINISH, doNextTween)
}
}
**请**看看这个链接:http://www.adobe.com/devnet/actionscript/articles/oop_as3.html – Marty 2011-06-15 02:51:55