# Horizontal textfield arrangement calculation

**URL:** <https://forum.kirupa.com/t/horizontal-textfield-arrangement-calculation/309060>\
**Category:** flash\
**Created:** [May 5, 2010, 10:46pm UTC](https://forum.kirupa.com/t/horizontal-textfield-arrangement-calculation/309060 "2010-05-05T22:46:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tyg3r](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/tyg3r/32/1341_2.png) [@Tyg3r](https://forum.kirupa.com/u/Tyg3r)\
**Post date:** [May 5, 2010, 10:46pm UTC](https://forum.kirupa.com/t/horizontal-textfield-arrangement-calculation/309060/1 "2010-05-05T22:46:52Z")

</div>

Hi there,

I’m trying to display a range of dynamic textfields, using an array.

I can place everything on the stage fine, but I just can’t figure out the maths behind placing each textfield next to each other horizontally. So, despite the length of the word, the spacing between each textfield is the same, e.g. 10px.

I’m sooooo eager for this one little calculation!

```auto
var myArray:Array = new Array("little", "looooooong", "huuuuuuuuuuuuuggeeeeee", "tiny");

var container_mc:MovieClip = new MovieClip();
container_mc.x = 80;
container_mc.y = 60;
addChild(container_mc);

for (var i:int = 0; i < myArray.length; i++)
{		
	//trace (myArray*);
		
	var myTextFormat:TextFormat = new TextFormat();
		myTextFormat.align = TextFormatAlign.CENTER;
		myTextFormat.size = 24;
						
	var myText:TextField = new TextField();  		
		myText.autoSize = TextFieldAutoSize.LEFT;
		myText.textColor = 0xA60000;
		myText.text = myArray*;
		myText.selectable = false;
		myText.setTextFormat(myTextFormat);
			
	myText.x = 0-myText.width/2*i+myText.width;//<<--- This is the bit I can't figure out!
		
	container_mc.addChildAt(myText, 0); 	

}

```

Cheers,

Mark
