# Spacing movie clips horizontally

**URL:** <https://forum.kirupa.com/t/spacing-movie-clips-horizontally/276243>\
**Category:** flash\
**Created:** [November 24, 2008, 9:08pm UTC](https://forum.kirupa.com/t/spacing-movie-clips-horizontally/276243 "2008-11-24T21:08:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)\
**Post date:** [November 24, 2008, 9:08pm UTC](https://forum.kirupa.com/t/spacing-movie-clips-horizontally/276243/1 "2008-11-24T21:08:25Z")

</div>

I am making a menu that is horizontal and changed by XML. Since I wont know the actual length of each menu item, I need to dynamically space them event horizontally. I am getting weird results with this:

```auto

function navLoaded(event:Event):void {
    var nav:XML = new XML(navLoader.data);
	var navLength = nav.children().length();
	nav.ignoreWhitespace = true;
	for (var i:uint = 0; i < navLength; i++)
	{
		var node = nav.menuitem*;
		var title = node.title;
		var content = node.content;
		var menuItem:MainMenuItem = new MainMenuItem();
		menuItem.id = i;
		menuItem.bg.alpha = 0;
		menuItem.txt.text = title;
		menuItem.txt.autoSize = TextFieldAutoSize.LEFT;
		menuItem.bg.width = menuItem.txt.width;
		menuItem.x = menuItem.width * i; //This doesnt seem to be working
		menuItem.addEventListener(MouseEvent.ROLL_OVER, navOver);
		menuItem.addEventListener(MouseEvent.ROLL_OUT, navOut);
		header.mainMenuHolder.addChild(menuItem);
	}
}

```

I have some menu items overlapping each other. Any idea how to get these guys spaced evenly?
