# Centering text on movieclip

**URL:** https://forum.kirupa.com/t/centering-text-on-movieclip/228445
**Category:** Uncategorized
**Created:** [June 7, 2007, 8:20pm UTC](https://forum.kirupa.com/t/centering-text-on-movieclip/228445 "2007-06-07T20:20:27Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ollu](https://avatars.discourse-cdn.com/v4/letter/o/ee59a6/32.png) [@ollu](https://forum.kirupa.com/u/ollu)
#### Post date: [June 7, 2007, 8:20pm UTC](https://forum.kirupa.com/t/centering-text-on-movieclip/228445/1 "2007-06-07T20:20:27Z")

</div>

Hi!  
I want to make my createTextField centered on my movieclip, does anyone know how this is done? I’ve tried using the texWidth/\_width property but it only makes it to narrow. Or is it possible to size the background fill to the length of the word?

```php

var aPoints:Array = ["one", "two", "three", "four"];
function printIt() {
    for (var i = 0; i<aPoints.length; i++) {
        _root.createEmptyMovieClip("box"+i+"_mc", this.getNextHighestDepth());
        var myCurrClip = _root["box"+i+"_mc"];
        myCurrClip.createTextField("my_txt", 1, 0, 0, 100, 40);
        myCurrClip.my_txt.autoSize = true;
        myCurrClip.my_txt.border = false;
        var my_fmt:TextFormat = new TextFormat();
        my_fmt.color = 0xB80000;
        my_fmt.size = 20;
        my_fmt.font = "verdana";
        my_fmt.align = "center";
        myCurrClip.my_txt.text = aPoints*;
        myCurrClip.beginFill(0x224488, 100);
        myCurrClip.moveTo(0, 0);
//This is no good way of setting the size ...
        myCurrClip.lineTo(myCurrClip.my_txt.textWidth*3, 0);
        myCurrClip.lineTo(myCurrClip.my_txt.textWidth*3, 30);
        myCurrClip.lineTo(0, 30);
        myCurrClip.endFill();
        myCurrClip._y = 10+50*i;
        myCurrClip._x = 10;
        myCurrClip.my_txt.setTextFormat(my_fmt);
    }
}
printIt();

```

kind regards, ollu
