# DisplayObjectContainer Handling Children with Same Name

**URL:** <https://forum.kirupa.com/t/displayobjectcontainer-handling-children-with-same-name/280471>\
**Category:** flash\
**Created:** [January 28, 2009, 2:38am UTC](https://forum.kirupa.com/t/displayobjectcontainer-handling-children-with-same-name/280471 "2009-01-28T02:38:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![McGuffin](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mcguffin/32/408_2.png) [@McGuffin](https://forum.kirupa.com/u/McGuffin)\
**Post date:** [January 28, 2009, 2:38am UTC](https://forum.kirupa.com/t/displayobjectcontainer-handling-children-with-same-name/280471/1 "2009-01-28T02:38:15Z")

</div>

Hey all, pretty simple question.

```auto

import flash.display.Sprite;

var sp1:Sprite = new Sprite( );
var sp2_1:Sprite = new Sprite( );
var sp2_2:Sprite = new Sprite( );

sp1.name = "sp1";
sp2_1.name = "sp2";
sp2_2.name = "sp2";

sp1.addChild( sp2_1 );
sp1.addChild( sp2_2 );

trace( sp1.getChildByName( "sp2" ) == sp2_1 ); // true
trace( sp1.getChildByName( "sp2" ) == sp2_2 ); // false

```

I’d assume from this that there is no correcting done for children with the same name being added to the same parent. I ask this question because I’m creating a structure that needs to mimic the display list and I’d like to keep behavior consistent.

Another question: I’d assume internally the children are saved in something similar to a Dictionary object, does anyone know if this is true? And then getChildByName simply does a foreach loop and returns the first match on a name?
