2011-01-13 59 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); 
}