這是我在一個連續加載圖像的圖庫中使用的代碼。當您必須打開不同的影像專輯並且必須消除動畫片段中以前加載的所有孩子時,我的問題纔會出現。當我加載新相冊時,我使用了您在此發佈的代碼: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