# setChildIndex doesnt work for me

**URL:** <https://forum.kirupa.com/t/setchildindex-doesnt-work-for-me/268357>\
**Category:** Uncategorized\
**Created:** [August 12, 2008, 11:56pm UTC](https://forum.kirupa.com/t/setchildindex-doesnt-work-for-me/268357 "2008-08-12T23:56:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wonsong82](https://avatars.discourse-cdn.com/v4/letter/w/22d042/32.png) [@wonsong82](https://forum.kirupa.com/u/wonsong82)\
**Post date:** [August 12, 2008, 11:56pm UTC](https://forum.kirupa.com/t/setchildindex-doesnt-work-for-me/268357/1 "2008-08-12T23:56:02Z")

</div>

```auto

var container_mc:MovieClip = new MovieClip();
addChild(container_mc);
 
var mc1:MovieClip = new Picture();
;
container_mc.addChild(mc1);
mc1.x = 0;

var mc2:MovieClip = new Picture();
container_mc.addChild(mc2);
mc2.x = 100;
 
var mc3:MovieClip = new Picture();
container_mc.addChild(mc3);
mc3.x = 200;

mc1.addEventListener(MouseEvent.CLICK, onTop);
mc2.addEventListener(MouseEvent.CLICK, onTop);
mc3.addEventListener(MouseEvent.CLICK, onTop);
function onTop(event:MouseEvent):void{
 container_mc.setChildIndex(event.target, 2);
}
 

```

im trying to read the book : Learning ActionScript 3.0 - a beginner’s guide from Rich Shupe with Zevan Rosser, O’REILLY published, and im only on chapter 4, but  
alot of codes examples arnt working and always giving me erriors.  
what am i doing wrong?

the code above gives me “implicit coercion of a value with static type Object to a possibly unrelated type flash.display:DisplayObject.container\_mc.setChildIndex(event.target, 2);”
