# Movie clip depths problem

**URL:** <https://forum.kirupa.com/t/movie-clip-depths-problem/172985>\
**Category:** Uncategorized\
**Created:** [December 20, 2005, 2:15am UTC](https://forum.kirupa.com/t/movie-clip-depths-problem/172985 "2005-12-20T02:15:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DrunkenMajestic](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/drunkenmajestic/32/237_2.png) [@DrunkenMajestic](https://forum.kirupa.com/u/DrunkenMajestic)\
**Post date:** [December 20, 2005, 2:15am UTC](https://forum.kirupa.com/t/movie-clip-depths-problem/172985/1 "2005-12-20T02:15:33Z")

</div>

can anyone tell me why this code gives the desired results with 4 lines originating at a point, and all staying connected to a button, while the second pice of code makes a single line (possibly of four segments) to the top left corner of the stage, and stays there?? i think something is going wrong with the depths, and also maybe because the line variables can’t be declared by using var in front of it.

```auto
var line1:MovieClip = _root.createEmptyMovieClip("mc", 1);
	var line2:MovieClip = _root.createEmptyMovieClip("mc", 2);
	var line3:MovieClip = _root.createEmptyMovieClip("mc", 3);
	var line4:MovieClip = _root.createEmptyMovieClip("mc", 4);
	line1.onEnterFrame = line2.onEnterFrame = line3.onEnterFrame = line4.onEnterFrame = function () {
		if(initialised) {
			this.clear();
			this.lineStyle(7.5, 0x999999, 100, false, "none", "square", "bevel");
			this.moveTo(375, 350);
			this.lineTo((_root['mainMenuButton' + (this.getDepth() - 1)]._x + 5), (_root['mainMenuButton' + (this.getDepth() - 1)]._y + 35));
		}
	}

```

code fragment 2:

```auto
for (i = 0; i < 4; i++) {
		_root['line' + i] = this.createEmptyMovieClip("line", i + 1);
		_root['line' + i].onEnterFrame = function () {
			if(initialised) {
				this.clear();
				this.lineStyle(7.5, 0x999999, 100, false, "none", "square", "bevel");
				this.moveTo(375, 350);
				this.lineTo((_root['mainMenuButton' + i]._x + 5), (_root['mainMenuButton' + i]._y + 35));
			}
		}
	}

```
