# Dinamically assigned depths

**URL:** <https://forum.kirupa.com/t/dinamically-assigned-depths/43478>\
**Category:** flash\
**Created:** [February 23, 2004, 4:51am UTC](https://forum.kirupa.com/t/dinamically-assigned-depths/43478 "2004-02-23T04:51:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![El\_Bicho](https://avatars.discourse-cdn.com/v4/letter/e/dbc845/32.png) [@El\_Bicho](https://forum.kirupa.com/u/El_Bicho)\
**Post date:** [February 23, 2004, 4:51am UTC](https://forum.kirupa.com/t/dinamically-assigned-depths/43478/1 "2004-02-23T04:51:19Z")

</div>

This code works fine:

```auto

depths = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
for (var i = 0; i<depths.length; i++) {
	_root.attachMovie("clip", "clip"+i, depths*);
	_root["clip"+i]._x = 30*i;
}

```

But when I try to change depths in a random way it doesen´t:

```auto

depths = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
depths2 = [];
while (depths.length) {
	depths2.push(depths.splice(Math.floor(Math.random()*depths.length), 1));
}
depths = depths2;
for (var i = 0; i<depths.length; i++) {
	_root.attachMovie("clip", "clip"+i, depths*);
	_root["clip"+i]._x = 30*i;
}

```

Instead of appearing the 10 clip appears only one.

Any hint?

Thanks.
