# Need to unload image before loading next one. Help!

**URL:** <https://forum.kirupa.com/t/need-to-unload-image-before-loading-next-one-help/322662>\
**Category:** flash\
**Created:** [May 29, 2011, 1:33pm UTC](https://forum.kirupa.com/t/need-to-unload-image-before-loading-next-one-help/322662 "2011-05-29T13:33:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![as3ohh](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@as3ohh](https://forum.kirupa.com/u/as3ohh)\
**Post date:** [May 29, 2011, 1:33pm UTC](https://forum.kirupa.com/t/need-to-unload-image-before-loading-next-one-help/322662/1 "2011-05-29T13:33:19Z")

</div>

Hey Friends, I am trying to figure out the best way to unload an image before loading another in my onComplete function.

I have tried using a removeChild call but it says the DisplayObject must be a child of the Caller - not sure what that means. I had help on this and am not familiar with all of it.

The images I use now have transparent parts that can be seen when they load over top of each other. I need that to stop. Your expertise is very much appreciated!

```auto

function loadImages(showN:int){

    preLoader.start();
             
    var urlRequest:URLRequest = new URLRequest(showData[showName]);

    marqLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onMarqProgressStatus);
    marqLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioMarqErrorListener);
    marqLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onMarqCompleteStatus);
    marqLoader.load(urlRequest);

    loadThumbs();

}

function ioMarqErrorListener(e:IOErrorEvent):void
{
    trace("ERROR DETECTED:" + IOErrorEvent);
    
    
    var urlRequest:URLRequest = new URLRequest("images/bannerFail.png");
    
    marqLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onMarqProgressStatus);
    marqLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioMarqErrorListener);
    marqLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onMarqCompleteStatus);
    marqLoader.load(urlRequest);

    
    
}

function onMarqProgressStatus(e:ProgressEvent):void
{
    
    var loadPercent:int = Math.ceil( ( e.bytesLoaded / e.bytesTotal ) * 100 );
    
}

function onMarqCompleteStatus(e:Event):void
{

    var imgArr = new Array();
    var imgloaderInfo:LoaderInfo = e.target as LoaderInfo;
    imgArr.push(imgloaderInfo.content);
    

    marqDisplay_mc.addChild(imgArr[0])
    

preLoader.stop();

}

```
