# AddChild, Remove Child, then adding again issue!

**URL:** <https://forum.kirupa.com/t/addchild-remove-child-then-adding-again-issue/296222>\
**Category:** flash\
**Created:** [September 11, 2009, 5:32am UTC](https://forum.kirupa.com/t/addchild-remove-child-then-adding-again-issue/296222 "2009-09-11T05:32:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aesthetics7](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@aesthetics7](https://forum.kirupa.com/u/aesthetics7)\
**Post date:** [September 11, 2009, 5:32am UTC](https://forum.kirupa.com/t/addchild-remove-child-then-adding-again-issue/296222/1 "2009-09-11T05:32:39Z")

</div>

.I am using addChild and removeChild. I have two main movieclips that this is based around. workss\_mc and work\_mc. workss\_mc is the slideshow, work\_mc is the selection grid. When you click on an object in work\_mc I am adding adding a child (workss\_mc) and removing work\_mc at the same time. That works fine; however, in workss\_mc I have a back button, this back button is used to remove works\_mc once it is removed it sends you back to work\_mc. Once you are back on work\_mc everything should work completely the same, however, it’s like it’s ignoring the code.

```
Does anyone have any idea why?

Here is the code for the button and Back button

```

```auto

backss_mc.addEventListener(MouseEvent.CLICK, backssClicked);
function backssClicked(event:MouseEvent) {
	trace("clicked");
	var work_mc = new mc_work();
	myParent.removeChild(this);
	myParent.addChild(work_mc);
	work_mc.x=225;
	work_mc.y=200;
	this.x=225;
	this.y=200;
}
/////////////////////////////////////

```

```auto

urbanthmb_mc.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(event:Event) {
	var workss_mc = new mc_workss();
	var work_mc = new mc_work();
	myParent.addChild(workss_mc); // we use that stage reference here
	myParent.removeChild(myParent.work_mc); // and here.
	workss_mc.x = 225;
	workss_mc.y = 200;
	workss_mc.gotoAndPlay("urbanflats");
	trace("I heard the event MouseEvent.CLICK");
}

```

```
The “back” button code is in workss_mc. The “button” code is in work_mc The purpose of the “back” button is to remove workss_mc off the stage.(ss for slideshow, ie workslideshow_mc)

```

The button code is in work\_mc

```
to show you what is going on here..
http://www.iankemp.com/beta/SILVERCOLLECTIVE2.swf

```

[URL=“[http://www.iankemp.com/beta/SILVERCOLLECTIVE2.swf](http://www.iankemp.com/beta/SILVERCOLLECTIVE2.swf)”]

```
click work &gt; click top left button(urbanflats) &gt; click back &gt; click top left button (urbanflats) again. You will notice that it is not aligning properly and the code for the buttons is disabled..Could this be a possible scope issue, I’m pretty puzzled here..
```
