# Moving objects (removechild etc...)

**URL:** <https://forum.kirupa.com/t/moving-objects-removechild-etc/307256>\
**Category:** flash\
**Created:** [March 31, 2010, 11:09am UTC](https://forum.kirupa.com/t/moving-objects-removechild-etc/307256 "2010-03-31T11:09:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trussy1000](https://avatars.discourse-cdn.com/v4/letter/t/59ef9b/32.png) [@Trussy1000](https://forum.kirupa.com/u/Trussy1000)\
**Post date:** [March 31, 2010, 11:09am UTC](https://forum.kirupa.com/t/moving-objects-removechild-etc/307256/1 "2010-03-31T11:09:20Z")

</div>

Hi I’m new here so it wouldn’t surprise me if I miss something simple but here goes:  
I am creating a game where you have to catch coconuts in a basket and when this happens the next one will fall (removechild() ). And the score is incremented etc…

My problem is that when it reaches the third coconut it freezes I feel that there is a flaw in my logic but I cannot see it for some reason:

function collisionDetector(event:Event):void {  
//Create the children to be deleted later  
addChild(coco1\_mc);  
addChild(coco2\_mc);  
addChild(coco3\_mc);

```
if ( coco1_mc.hitTestObject(basket_mc) ) {
	coco_hits += 1;
	updateHitText();
	coco3_mc.y += dy; //Code for movement(function declared earlier)
	removeChild(coco1_mc);
	
}
else if ( coco1_mc.hitTestObject(bottomz) ) {
	  coco_miss += 1;
	  updateHitText();
	  coco3_mc.y += dy;
	  removeChild(coco1_mc);
}
if (coco3_mc.hitTestObject(basket_mc) ) {
	coco_hits += 1;
	updateHitText();
	coco5_mc.y += dy;
	removeChild(coco3_mc);
}
else if (coco3_mc.hitTestObject(bottomz) ) {
	coco_miss++;
	updateHitText();
	coco5_mc.y += dy;
	removeChild(coco3_mc);
}

```

Any help would be appreciated, thanks, Tom
