# For loop + preloading each item

**URL:** https://forum.kirupa.com/t/for-loop-preloading-each-item/194844
**Category:** Uncategorized
**Created:** [July 26, 2006, 6:08pm UTC](https://forum.kirupa.com/t/for-loop-preloading-each-item/194844 "2006-07-26T18:08:20Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![nitras](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/nitras/32/1475_2.png) [@nitras](https://forum.kirupa.com/u/nitras)
#### Post date: [July 26, 2006, 6:08pm UTC](https://forum.kirupa.com/t/for-loop-preloading-each-item/194844/1 "2006-07-26T18:08:20Z")

</div>

hello there again  
i am working on my portfolio  
and it’s getting rather big.  
so i am in need of a steady preloader that loads every single image

the images are the buttons aswell  
so one button is : btn \> btn\_txt & TN\_holder  
//TN\_holder isn’t coded below, but this is the idea

plz bare in mind that the holder in the code refers to whats going to be the holder for the big image, TH holder is the image holder inside the button wich is being attached when the function loads

how can i say that it needs to preload in the TN\_holder each item before displaying the button(aka the txt, the image itself) plz?

for some reason i don’t find it.  
this is my code, yet, the urls are muffled out for obvious reasons.

so in this example it only loads text cuz this is my secure version, as in, i know this works fine for me

now i want this to preload the images for each image in the array when it enters the screen, offcourse by this i’ll know how to preload when i click for a larger image

i know about the movieclip loader class, but i am totally unaware how to implent it here

i hope my text is a bit clear, it’s all still in progress  
hoping on some help, i tried different things but they seem to mess up what works at this point.

```auto

var ScanPictureDir:XML = new XML();
ScanPictureDir.ignoreWhite = true;
ScanPictureDir.onLoad = function() {
    var nodes = this.firstChild.childNodes;
    for (p=0; p<nodes.length; p++) {
        var photoSub = attachMovie("btn", "photoSub"+p, 100+p);
        photoSub._x = 501;
        photoSub._y = News_name._y+photoSub._height*p;
        photoSub.btn_txt.autoSize = true;
        photoSub.btn_txt.border = false;
        photoSub.btn_txt.textColor = normal_color;
        photoSub.btn_txt.backgroundColor = normal_background;
        photoSub.btn_txt.text = nodes[p].firstChild.nodeValue;
        photoSub.alphaTo(90, p*0.09, "easeOutSine");
        photoSub.id = p;
        photoSub.onRollOver = function() {
            this.btn_txt.textColor = focus_color;
            //this.btn_txt.border = false;
        };
        photoSub.onRollOut = function() {
            this.btn_txt.textColor = normal_color;
            this.btn_txt.backgroundColor = normal_background;
            //this.btn_txt.border = false;
        };
        photoSub.onRelease = function() {
            if (selectedFotosub != null) {
                selectedFotosub.enabled = true;
            }
            selectedFotosub = this;
            selectedFotosub.enabled = false;
            //this.btn_txt.border = false;
            News_image.text = nodes[this.id].firstChild.nodeValue;
            imagePath = http://url"+nodes[this.id].firstChild.nodeValue;
            holder.load(imagePath)
            //force fit in holder
            if (holder._width>150 && holder._height>100) {
                holder._yscale = 25;
                holder._xscale = 25;
                
            }
            
        };
    }
};
ScanPictureDir.load("url.php");

```

thank you
