# Disappearing AS generated movieclips and textfields

**URL:** <https://forum.kirupa.com/t/disappearing-as-generated-movieclips-and-textfields/262052>\
**Category:** flash\
**Created:** [June 2, 2008, 11:10pm UTC](https://forum.kirupa.com/t/disappearing-as-generated-movieclips-and-textfields/262052 "2008-06-02T23:10:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mvatki](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@mvatki](https://forum.kirupa.com/u/mvatki)\
**Post date:** [June 2, 2008, 11:10pm UTC](https://forum.kirupa.com/t/disappearing-as-generated-movieclips-and-textfields/262052/1 "2008-06-02T23:10:55Z")

</div>

This issue seems rather bizarre to me but I suspect that what I am missing is something obvious. The visual output that I would expect from the code below is a diagonal string of ten number signs each followed by its own value of _i._ However, instead I find a “#9” in the bottom right hand corner.

The output box displays:

```auto

#0
outer0
#1
outer1
etc...

```

```auto

    var i = 0;
    var myObj:Array = new Array();
    while(i<10){
        myObj* = "outer"+i;
        this.createEmptyMovieClip("outer"+i, 0);
        this[myObj*]._x = i*50;
        this[myObj*]._y = i*50;
        this[myObj*].createTextField("inner", 1, 0, 0, 100, 100);
        this[myObj*].inner.text = "#"+i;
        trace(this[myObj*].inner.text);
        trace(myObj*);
        i++;
    }

```

Shouldn’t the movieclip generated by _createEmptyMovieClip()_ persist through each iteration of the while loop instead of disappearing every time _i_ changes? I can see that happening when using the debugger. What should I do to cause each of the movie clips generated to remain on the screen?

Thanks,  
M. Vatki

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [June 3, 2008, 3:28am UTC](https://forum.kirupa.com/t/disappearing-as-generated-movieclips-and-textfields/262052/2 "2008-06-03T03:28:59Z")

</div>

You’re creating all of them at the same depth (0) which isn’t possible. You’ll have to make a new depth for each one. Something like this:

```auto
var i = 0;
var myObj:Array = new Array();
while (i < 10) {
	myObj* = "outer" + i;
	this.createEmptyMovieClip("outer" + i, i);
	this[myObj*]._x = i * 50;
	this[myObj*]._y = i * 50;
	this[myObj*].createTextField("inner", 1, 0, 0, 100, 100);
	this[myObj*].inner.text = "#" + i;
	trace(this[myObj*].inner.text);
	trace(myObj*);
	i++;
}

```

---

<div class="post-metadata">

**Author:** ![mvatki](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@mvatki](https://forum.kirupa.com/u/mvatki)\
**Post date:** [June 3, 2008, 12:31pm UTC](https://forum.kirupa.com/t/disappearing-as-generated-movieclips-and-textfields/262052/3 "2008-06-03T12:31:04Z")

</div>

> [@TheCanadian;2335276](#):
>
> You’re creating all of them at the same depth (0) which isn’t possible.

Thanks for the quick response. I didn’t know that depth differences were mandatory :). It makes sense now though.
