# Dynamic button text at the hitstate

**URL:** <https://forum.kirupa.com/t/dynamic-button-text-at-the-hitstate/275975>\
**Category:** flash\
**Created:** [November 20, 2008, 9:13pm UTC](https://forum.kirupa.com/t/dynamic-button-text-at-the-hitstate/275975 "2008-11-20T21:13:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nkamp](https://avatars.discourse-cdn.com/v4/letter/n/cc9497/32.png) [@nkamp](https://forum.kirupa.com/u/nkamp)\
**Post date:** [November 20, 2008, 9:13pm UTC](https://forum.kirupa.com/t/dynamic-button-text-at-the-hitstate/275975/1 "2008-11-20T21:13:16Z")

</div>

Hello,

Last time I get a question “How dow I make button text dynamically”. Alex Lexcux send me the answer:

```auto

var t3:TextField = (btnFeest.overState as DisplayObjectContainer).getChildAt(1) as TextField;
t3.text = 'Animals';

```

But except one thing: What is state for hit,

```auto

var t5:TextField = (btnFeest.hitTestState as DisplayObjectContainer).getChildAt(1) as TextField;
t5.text = 'Animals';

```

But then I get the next error: “Error #1009: Cannot access a property or method of a null object reference.”  
I don’t understand because overState/DownState is working fine. Why not the hit state? Has it something todo with the stage?

And I see one more thing. If I go with the mouseover the button the mentioned text is not close to the mousepointer/button. Is is possible to give a position to the text relatief to the mousepointer like t3.x = mouse.position??

Thanks in advance.

Nico
