# Emptying movieclip?

**URL:** <https://forum.kirupa.com/t/emptying-movieclip/275670>\
**Category:** Uncategorized\
**Created:** [November 17, 2008, 2:36pm UTC](https://forum.kirupa.com/t/emptying-movieclip/275670 "2008-11-17T14:36:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![panopticon\_](https://avatars.discourse-cdn.com/v4/letter/p/a3d4f5/32.png) [@panopticon\_](https://forum.kirupa.com/u/panopticon_)\
**Post date:** [November 17, 2008, 2:36pm UTC](https://forum.kirupa.com/t/emptying-movieclip/275670/1 "2008-11-17T14:36:45Z")

</div>

i’m building a little pixel house and i’ve got a problem with the redrawing of the house

_link deleted_

if you test my swf you can see the bug. at first when you click on the “up” button it seems to work nicely (in fact it only seems to…) but if you click the “down” button it becomes visible that the house is drawn over and over again.

i know i have to “empty” my movieclip with the house in it before i call the drawing function again but i have no clue how to do it properly ☹

any suggestions?

```auto

var anz_stockwerke:Number = 1;
var fund_x:Number = 10;
var fund_y:Number = 480;

var haus_holder:MovieClip = new MovieClip();
haus_holder.x = 0;
haus_holder.y = 0;
addChild(haus_holder);

function drawhouse()
{

var fundament_mc:MovieClip = new Fundament();
fundament_mc.x = fund_x;
fundament_mc.y = fund_y;
haus_holder.addChild(fundament_mc);
var geschosse:Array = new Array();

	
	for (var i:Number = 1; i <= anz_stockwerke; i++) {
	
	geschosse* = new Hausgeschoss();
	geschosse*.x = fund_x;
	geschosse*.y = fund_y - i * 50;
	haus_holder.addChild(geschosse*);
	var dachpos:Number = geschosse*.y;
	}

var dach_mc:MovieClip = new Dach();
dach_mc.x = fund_x;
dach_mc.y = dachpos - 55;
haus_holder.addChild(dach_mc);
addChild(haus_holder);
//trace("+1");

}

drawhouse();

up_btn.addEventListener(MouseEvent.MOUSE_DOWN, clickup);

function clickup(e:MouseEvent):void
{
	if (anz_stockwerke < 8)
	{
	anz_stockwerke++;
	drawhouse();
	}
}

down_btn.addEventListener(MouseEvent.MOUSE_DOWN, clickdown);

function clickdown(e:MouseEvent):void
{
	
	if (anz_stockwerke > 1)
	{
	anz_stockwerke = anz_stockwerke - 1;
	drawhouse();
	}
	
}

```

some german words there…  
dach = roof  
fundament = bottom of the house  
geschoss/stockwerk = level

each part of the pixel building is in the library (as a movieclip)
