2011-01-13 53 views
0

我正在嘗試執行圖片庫。最初我無法顯示存儲在陣列中的縮略圖。而是繼續顯示相同的縮略圖。與解決我面臨另一個問題..我不斷收到錯誤錯誤#2044:未處理的ioError :.文本=錯誤#2124:加載文件是未知類型。當我點擊縮略圖加載.txt文件時。無法顯示陣列中的文件

hw我可以命令預加載器來跟蹤下載的進度嗎?

public function loadImage(filename:String):void 
     { 
      // show the preloader 
      preloader.visible = true; 

    // set the source to the UILoader to the full size image to load and display 

      addChild(preloader); 

      // command the preloader to track the progress of the download 
      var loadWindow:UILoader;  
     preloader.trackLoading("LOADING: " + (loader*100).toFixed(0) + "%"); 


     } 
+0

使用{}按鈕將代碼格式化爲源代碼碼。另外,爲您的問題添加更多標籤使人們更有可能回答。我這次爲你做了。 – weltraumpirat 2011-01-13 14:14:20

+0

好的,謝謝你會這麼做... – sjl 2011-01-14 06:14:29

+1

這個問題已經完全與標題一起編輯。當您獲得答案並請選擇最佳答案時,請提出一個新問題。 – loxxy 2011-01-14 06:54:15

回答

1

其實很明顯。你不斷覆蓋相同的變量。

thumbs.textFile =「text/picture1.txt」;

thumbs.textFile =「text/picture2.txt」; //丟失第一個值

thumbs.textFile =「text/picture3.txt」; //第二個值丟失

...等等

所以,在這裏你會繼續增加在循環的每次迭代的最後一個即第七圖像。

看看weltraumpirat的答案是正確的代碼。


而且你並不真正需要的文件用名稱爲IMAGE_1,IMAGE_2,IMAGE_3安排....

如果他們已經安排正因爲如此,你可能會究竟做贈品都沒有那些陣列。我不知道會有多高效或更好,但爲了時間的緣故,我真的會跳到類似以下的解決方案:

for (var i:int = 0; i <7; i++) 
    { 
     var thumbs:MyUIThumbnail = new MyUIThumbnail();  
     thumbs.y = 43 * i;  
     thumbs.image   = "images/image" +i +".jpg"; 
     thumbs.textFile  = "text/picture" +i +".txt"; 
     thumbs.imageFullSize = full_image_mc; 
     thumbs.infoText  = info; 
     thumbs.loadThumbnail("images/image"+i+"_thumb.jpg");  
     addChild(thumbs); 
    } 
0

您沒有正確訪問陣列。看看[] operator

for (var i:int = 0; i <7; i++) { 
    var thumbs:MyUIThumbnail = new MyUIThumbnail(); 

    thumbs.y = 43 * i; 

    thumbs.image = images[i]; 
    thumbs.textFile = textFiles[i]; 
    thumbs.imageFullSize = full_image_mc; 
    thumbs.infoText = info; 
    thumbs.loadThumbnail(thumbnails[i]); 

    addChild(thumbs); 
}