# Loading next photo keeps previous on stage

**URL:** <https://forum.kirupa.com/t/loading-next-photo-keeps-previous-on-stage/298399>\
**Category:** Uncategorized\
**Created:** [October 18, 2009, 9:57am UTC](https://forum.kirupa.com/t/loading-next-photo-keeps-previous-on-stage/298399 "2009-10-18T09:57:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tristessa](https://avatars.discourse-cdn.com/v4/letter/t/a88e4f/32.png) [@tristessa](https://forum.kirupa.com/u/tristessa)\
**Post date:** [October 18, 2009, 9:57am UTC](https://forum.kirupa.com/t/loading-next-photo-keeps-previous-on-stage/298399/1 "2009-10-18T09:57:04Z")

</div>

Greetings once more.

Been fiddling around with AS 3 once more and i have this issue.

I got a mc on stage named imageArea

each next or previous click triggers function that increments the xml node plus some extras and then does the loadImage function.

when i click next image the correct image loads, but the previous one is still in the display.  
how i prevent that please?

```auto

var imageLoader:Loader;
function loadImage (url:String):void
{
    // Set properties on imageLoader object
     imageLoader = new Loader();
    imageLoader.load (new URLRequest(url));
    imageLoader.contentLoaderInfo.addEventListener (ProgressEvent.PROGRESS, imageLoading);
    imageLoader.contentLoaderInfo.addEventListener (Event.COMPLETE, imageLoaded);
}

function imageLoaded (e:Event):void
{
    // Load Image is completed.
    imageArea.x = (stage.stageWidth/2) - imageArea.loc[0];
    imageArea.y = (stage.stageHeight/2) - imageArea.loc[1];
    imageArea.addChild (imageLoader);
}
loadImage ("myimage.jpg");

```

many thanks
