# Using getChildAt with a sprite conatiner is removing a child from the container

**URL:** https://forum.kirupa.com/t/using-getchildat-with-a-sprite-conatiner-is-removing-a-child-from-the-container/302902
**Category:** Uncategorized
**Created:** [January 9, 2010, 5:01pm UTC](https://forum.kirupa.com/t/using-getchildat-with-a-sprite-conatiner-is-removing-a-child-from-the-container/302902 "2010-01-09T17:01:28Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mnli19](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@mnli19](https://forum.kirupa.com/u/mnli19)
#### Post date: [January 9, 2010, 5:01pm UTC](https://forum.kirupa.com/t/using-getchildat-with-a-sprite-conatiner-is-removing-a-child-from-the-container/302902/1 "2010-01-09T17:01:28Z")

</div>

I am trying to get an image object from one sprite container and adding it to another sprite container. But when I use GetChildAt for this, it will remove the object from the parent sprite and place it inside the other.

Code:  
**sprContainer1.addChildAt(sprContainer2.getChildAt(1),0);**

Problem is when I run this code sprContainer2.numChildren is getting reduced by 1, which seems that this code removes a child from sprcontainer2. any thoughts why this is happening?
