# Accessing textWidth of a Text component

**URL:** <https://forum.kirupa.com/t/accessing-textwidth-of-a-text-component/307011>\
**Category:** Uncategorized\
**Created:** [March 26, 2010, 3:02am UTC](https://forum.kirupa.com/t/accessing-textwidth-of-a-text-component/307011 "2010-03-26T03:02:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![geestring](https://avatars.discourse-cdn.com/v4/letter/g/e19b73/32.png) [@geestring](https://forum.kirupa.com/u/geestring)\
**Post date:** [March 26, 2010, 3:02am UTC](https://forum.kirupa.com/t/accessing-textwidth-of-a-text-component/307011/1 "2010-03-26T03:02:05Z")

</div>

```auto

import mx.core.mx_internal;
use namespace mx_internal;

   var txtIt:Text = new Text();

                txtIt.text = full_array[t][0];
                txtIt.width = 700;
                txtIt.buttonMode = true;
                txtIt.mouseChildren = false;
                txtIt.selectable = false;
                txtIt.y = t * 30;

                var txtfld:TextField = txtIt.getTextField() as TextField;
                trace(txtfld.textWidth);

                myCanvas.addChild(txtIt);

```

I get a TypeError: Error #1009: Cannot access a property or method of a null object reference.

how do I get at that textWidth?
