2011-09-23 86 views
0

我正在從xml文件加載圖像。我希望圖像在顯示時具有標準寬度。在AS3.0中設置加載圖像的大小

下面是做圖像處理的代碼片段:

var allThumbs:MovieClip = new MovieClip(); 
addChild(allThumbs); 

allThumbs.width = 200; 
allThumbs.height = 200; 

galleryPane.source = allThumbs; 

和下面是loades圖像中的一個:

function loadTheThumbs() { 

    var c:Number = 0; 

    while(c < totalCats) { 

    var thumbLoader:Loader = new Loader(); 
    var thumbRequest:URLRequest = new URLRequest(catImgList[c]); 
    thumbLoader.load(thumbRequest); 
    thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, whenThumbLoaded); 

     function whenThumbLoaded(e:Event):void { 
      allThumbs.addChild(thumbLoader); 
     } 
    c++; 
    } 


} 

一切工作酷我插入

allThumbs.width = 200; 
allThumbs.height = 200; 

這一行,我想在圖像顯示在ScrollPa之前調整圖像大小東北。

我看到其他線程在這裏,但沒有幫助...

所以也許任何想法,我應該怎麼辦呢?

在此先感謝。

+0

是什麼,當你添加這些行,你有問題的規模? – Mansuro

+0

@Mansuro沒有顯示任何內容 – mrGott

+0

對於上帝而言,不要在函數內嵌套函數。當然,不要在循環中嵌套一個函數 –

回答

1
function whenThumbLoaded(e:Event):void { 
     allThumbs.addChild(thumbLoader); 
    } 

你可能想建立圖像的位置,在這裏

function whenThumbLoaded(e:Event):void { 
     thumbloader.x = c * 220; 
     thumbloader.y = 0; 
     thumbloader.width = 200; 
     thumbloader.height = 200; 
     allThumbs.addChild(thumbLoader); 
    }