# Image gallery load() woes

**URL:** <https://forum.kirupa.com/t/image-gallery-load-woes/240899>\
**Category:** Uncategorized\
**Created:** [October 8, 2007, 4:08am UTC](https://forum.kirupa.com/t/image-gallery-load-woes/240899 "2007-10-08T04:08:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zubin101](https://avatars.discourse-cdn.com/v4/letter/z/51bf81/32.png) [@zubin101](https://forum.kirupa.com/u/zubin101)\
**Post date:** [October 8, 2007, 4:08am UTC](https://forum.kirupa.com/t/image-gallery-load-woes/240899/1 "2007-10-08T04:08:47Z")

</div>

I’ve built a basic image gallery which has multiple thumbnails/objects which calls a common displayImage class object with a shared preloader to load the image.

The problem is that when the user decides to click on another or multiple thumbnails **before the current preloader completes,** i expected that the new call would override and interupt the ongoing load() container and preload the last image clicked, instead it seems to **add** to the ongoing load() object leading to wacky results (like having a loadedPercent values over 100% and the other images being loaded up instead). What’s going on? I’ve tried to nullify the ongoing load() object everytime it calls a new image, but to no avail…

```php
public function loadImage(url:URLRequest) {
   try{imgLoader.close();}catch(error:Error) {};
 
   imgLoader.unload();
   imgLoader = null;
   imgLoader = new Loader();
   imgLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress);
   imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
   imgLoader.load(url);
  }

```

is there a better way to go about this?
