# Reuse loaded object

**URL:** <https://forum.kirupa.com/t/reuse-loaded-object/293768>\
**Category:** flash\
**Created:** [August 3, 2009, 2:52pm UTC](https://forum.kirupa.com/t/reuse-loaded-object/293768 "2009-08-03T14:52:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vxd](https://avatars.discourse-cdn.com/v4/letter/v/848f3c/32.png) [@vxd](https://forum.kirupa.com/u/vxd)\
**Post date:** [August 3, 2009, 2:52pm UTC](https://forum.kirupa.com/t/reuse-loaded-object/293768/1 "2009-08-03T14:52:24Z")

</div>

Hi All,

I’ve come across a problem. I’m developing a gallery and I’ve just relised I’ve been creating a new set of thumbnails each time I click on the image category.

There are four Categories and everytime I click on a category a new set of thumbnails gets created.  
How would I go about reusing the loaded thumbnails.

I’m assuming I would need to create a separate Array to store the loaded thumbnail from each category.  
I am able to create the Array but how do I tell flash that the Loaded objects are in the array so don’t create a new Loader and a new thumbHolder.

```auto
        private function loadThumbnail():void {
          
            //trace(xmlLoader.xmlData.children()[index].children().attribute("thumb").length())
            for (var i:int = 0; i<xmlLoader.xmlData.children()[index].children().attribute("thumb").length(); i++) {
                //Create a new thumbnail holder
                thumbHolder = new Sprite();
                //Create a new loader for the thumbnails
                thumbLoader = new Loader();
                //Load the thumbnails
                thumbLoader.load(new URLRequest("xml file where the thumbs are store");
                //x and y of thumbnail holder
                thumbHolder.x = i* 50;
                thumbHolder.y = 200;
                //Add thumbHolder to the stage
                addChild(thumbHolder);
                //add thumbLoader to the stage
                thumbHolder.addChild(thumbLoader);
                //Mouse children off
                thumbHolder.mouseChildren = false;
                //Button mode on
                thumbHolder.buttonMode = true;
                //Name of the thumbnails
                thumbHolder.name = "xml file where the thumbs are store");
                //Call loadImage when the thumbnail is clcked
                thumbHolder.addEventListener(MouseEvent.CLICK, loadImage);
                
            }//end loop

        }//loadThumbnail()

```
