# Can this code be shortened... with function?

**URL:** <https://forum.kirupa.com/t/can-this-code-be-shortened-with-function/115173>\
**Category:** Uncategorized\
**Created:** [July 6, 2004, 7:03am UTC](https://forum.kirupa.com/t/can-this-code-be-shortened-with-function/115173 "2004-07-06T07:03:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rabi](https://avatars.discourse-cdn.com/v4/letter/r/848f3c/32.png) [@rabi](https://forum.kirupa.com/u/rabi)\
**Post date:** [July 6, 2004, 7:03am UTC](https://forum.kirupa.com/t/can-this-code-be-shortened-with-function/115173/1 "2004-07-06T07:03:03Z")

</div>

Dear Friends,  
Please help me with this code.  
Could it be made into a function and achieve the same pattern in code…

```auto
onClipEvent (enterFrame) {
	_parent.a0._height = _parent.a0.textHeight +15;
	// 15 for bold text and capital letters
	_parent.a0._width = 235;
	_parent.a0._y = 0;
	//
	_parent.a1._height = _parent.a1.textHeight +15;
	_parent.a1._width = 235;
	_parent.a1._y = _parent.a0._y + _parent.a0._height;
	//
	_parent.a2._height = _parent.a2.textHeight +15;
	_parent.a2._width = _parent.a1._width;
	_parent.a2._y = _parent.a1._y + _parent.a1._height;
	//
	_parent.a3._height = _parent.a3.textHeight+15;
	_parent.a3._width = _parent.a2._width;
	_parent.a3._y = _parent.a2._y + _parent.a2._height;
	//
	_parent.a4._height = _parent.a4.textHeight+15;
	_parent.a4._width = _parent.a3._width;
	_parent.a4._y = _parent.a3._y + _parent.a3._height;
	//
	_parent.a5._height = _parent.a5.textHeight15;
	_parent.a5._width = _parent.a4._width;
	_parent.a5._y = _parent.a4._y + _parent.a4._height;
	//
	//trace(a0.textHeight);
	//trace(a0._height);
}

```

I want to make textBoxes align with each other based on previous text height and location in Y-coordinates. Please suggest something.

Thank you for your time. :cons:
