0
votes

i'm trying to do an image gallery. initially i was not able to display the thumbnails stored in the array. instead it keep showing the same thumbnails. with that solve i'm facing another problem.. i'm keep getting an error Error #2044: Unhandled ioError:. text=Error #2124: Loaded file is an unknown type. when i click on the thumbnail to load the .txt file.

hw can i command the pre-loader to track the progress of the download?

 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) + "%");


        }
2
Use the {} button to format your code as source code. Also, adding more tags to your question makes it more likely that people will answer. I did that for you this time. - weltraumpirat
The question has been completely edited along with title. Please ask a new question when you get an answer & select the best answer. - loxxy

2 Answers

1
votes

It is quite obvious actually. You are continuously overwriting the same variable.

thumbs.textFile = "text/picture1.txt";

thumbs.textFile = "text/picture2.txt"; //1st value lost

thumbs.textFile = "text/picture3.txt"; //2nd value lost

...and so on

So here you will keep on adding the last one i.e the seventh image in every iteration of the loop.

look at weltraumpirat's answer for the right code.


Also you don't really need to arrange the files with names as Image_1, Image_2, Image_3....

If they were already arranged as such, you could have actually done aways without all those arrays. I don't know how efficient or better that would have been, but for time sake, I honestly would have jumped on to a solution something like the following:

 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
votes

You are not accessing the arrays correctly. Have a look at the [] 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);
}