# Smart unload movieclip

**URL:** https://forum.kirupa.com/t/smart-unload-movieclip/172706
**Category:** flash
**Created:** [December 17, 2005, 12:02am UTC](https://forum.kirupa.com/t/smart-unload-movieclip/172706 "2005-12-17T00:02:00Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![niakmo](https://avatars.discourse-cdn.com/v4/letter/n/bbe5ce/32.png) [@niakmo](https://forum.kirupa.com/u/niakmo)
#### Post date: [December 17, 2005, 12:02am UTC](https://forum.kirupa.com/t/smart-unload-movieclip/172706/1 "2005-12-17T00:02:00Z")

</div>

I’ve this function which generates some emptymovieclips and then adds a picture to them. Now I want to remove all the pictures generated bij one call of the function. What is the best way to do this. I was thinking of adding a listener to every generated movieclip to listen to a call from a specific function and then to remove itself. But I’m not sure how to inplement that, or if its possible.

```auto
function showPictures(amount:Number, size:Number, ring:Number):Void
	{
		for(i = 0; i < amount; i++)
			{
				tmp = _root.holder.createEmptyMovieClip(j+"n", j);
				tmp2 = tmp.createEmptyMovieClip(j+"clipholder", j);				
				
				var mclListener:Object = new Object();
				mclListener.onLoadInit = function(target_mc:MovieClip)
				{
					target_mc._width = size;
					target_mc._height = size;
					target_mc.filters = [dropShadow];
				}
				var image_mcl:MovieClipLoader = new MovieClipLoader();
				image_mcl.addListener(mclListener);
				image_mcl.loadClip("pictures/"+j+".jpg", tmp2);
				trace("pictures/"+j+".jpg");
				
				j++;
				
				if(ring == 2)
					{
					tmp._x = klein*[0];
					tmp._y = klein*[1];
					}
				if(ring == 1)
					{
					tmp._x = middel*[0];
					tmp._y = middel*[1];
					}
				if(ring == 0)
					{
					tmp._x = groot*[0];
					tmp._y = groot*[1];
					trace("hier");
					}
			}
	}

```
