# addChildAt not working: RangeError: Error #2006

**URL:** https://forum.kirupa.com/t/addchildat-not-working-rangeerror-error-2006/288181
**Category:** flash
**Created:** [May 12, 2009, 3:56pm UTC](https://forum.kirupa.com/t/addchildat-not-working-rangeerror-error-2006/288181 "2009-05-12T15:56:09Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![rib](https://avatars.discourse-cdn.com/v4/letter/r/ecd19e/32.png) [@rib](https://forum.kirupa.com/u/rib)
#### Post date: [May 12, 2009, 3:56pm UTC](https://forum.kirupa.com/t/addchildat-not-working-rangeerror-error-2006/288181/1 "2009-05-12T15:56:09Z")

</div>

i simply load a playermenu from the library and then attach the whole player\_menu to the stage.  
when doing it with addChild it works, however when i specify a index it reports that error. (i need to use it because i want to control the indexing of movieclips)  
i am just not able to add a child with addChildAt, whats the error here?

```php

//menu
var player_menu:MovieClip = new MovieClip();
var player_menu_sub:playermenu = new playermenu();            
player_menu.addChild(player_menu_sub);
player_menu.y=174;
this.addChildAt(player_menu, 6);
output.text=this.getChildIndex(player_menu).toString();    

```
