# Replace the setChildByIndex order

**URL:** <https://forum.kirupa.com/t/replace-the-setchildbyindex-order/327991>\
**Category:** flash\
**Created:** [April 11, 2012, 11:43am UTC](https://forum.kirupa.com/t/replace-the-setchildbyindex-order/327991 "2012-04-11T11:43:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MFRS](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@MFRS](https://forum.kirupa.com/u/MFRS)\
**Post date:** [April 11, 2012, 11:43am UTC](https://forum.kirupa.com/t/replace-the-setchildbyindex-order/327991/1 "2012-04-11T11:43:44Z")

</div>

I have my background added in the first world of my platform based game like this:

```auto
else if (lvlArray* == 'ROCKYHILLS') {            
                    var newRockyHills:backRocky = new backRocky;
                    newRockyHills.x = newRockyHills.width / 2;
                    newRockyHills.y = newRockyHills.height / 2;
                    //newRockyHills.scaleX *= 1.2;
                    currentStage.addChild(newRockyHills);
                    currentStage.setChildIndex(newRockyHills, 0);
                }

```

Next i want to add the new background, so i wrote this:

```auto
else if (lvlArray* == 'FIERYPITS') {
                    
                    var newFieryPits:bgFieryPits = new bgFieryPits;
                    newFieryPits.x = newFieryPits.width / 2;
                    newFieryPits.y = newFieryPits.height / 2;
                    //newRockyHills.scaleX *= 1.2;
                    currentStage.addChild(newFieryPits);
                    currentStage.setChildIndex(newFieryPits, 0);
                    currentStage.setChildIndex(newRockyHills, 1);
                }

```

But it doesn’t work. **How can i change the order and put the new Bg on top?**
