# Unloading images

**URL:** https://forum.kirupa.com/t/unloading-images/316056
**Category:** Uncategorized
**Created:** [November 11, 2010, 1:18pm UTC](https://forum.kirupa.com/t/unloading-images/316056 "2010-11-11T13:18:24Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Batterman](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@Batterman](https://forum.kirupa.com/u/Batterman)
#### Post date: [November 11, 2010, 1:18pm UTC](https://forum.kirupa.com/t/unloading-images/316056/1 "2010-11-11T13:18:24Z")

</div>

how do I unload images from this function?:

```auto
        
private function loadImage():void
{
	var spacing:int = 10;
            if(_array.length > 0)
            {
                var loader:Loader = new Loader();
                Main.instance.workinfobox.rect.addChild(loader);

                var request:URLRequest = new URLRequest(_array[0].path); //Loads first item in the array each time.
                loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
                loader.y = _lastY + _lastHeight + spacing;
				if(starting == true){
					loader.y += 150;
				}
                loader.load(request);

                _lastY = loader.y; //We set after so we are ready for the next.

                _array.shift(); //Remove the first item from the array.
				starting = false;
            }
        }
        function onImageLoaded(e:Event):void
        {
            _lastHeight = e.target.height;
            loadImage(); //Attempt to load another image if the array isn't empty.
        }
}

```
