# Simple Experiment With Dynamic Text and a Button

**URL:** <https://forum.kirupa.com/t/simple-experiment-with-dynamic-text-and-a-button/325436>\
**Category:** flash\
**Created:** [October 15, 2011, 12:37pm UTC](https://forum.kirupa.com/t/simple-experiment-with-dynamic-text-and-a-button/325436 "2011-10-15T12:37:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![GoldenSilence](https://avatars.discourse-cdn.com/v4/letter/g/958977/32.png) [@GoldenSilence](https://forum.kirupa.com/u/GoldenSilence)\
**Post date:** [October 15, 2011, 12:37pm UTC](https://forum.kirupa.com/t/simple-experiment-with-dynamic-text-and-a-button/325436/1 "2011-10-15T12:37:20Z")

</div>

I wanted to conduct a simple experiment, where I update a dynamic text field on the click of a button. Well, it throws no errors, but it doesn’t work, and I can’t figure out where I went wrong.

```auto
import flash.events.MouseEvent;

var currentText:Number;

currentText = 100;

attackButton.addEventListener(MouseEvent.CLICK , onAttackClick);

 function onAttackClick(event:MouseEvent):void
{
    currentText = currentText-1;
    trace (currentText);
    updateDisplay();
}

function updateDisplay(){                                      
    healthText.text = String(currentText);
}

```

CurrentText is updated with each button click, but the text field goes from 100 to blank once I click the button.

I have searched the internet, but can’t find anything close to this.

Thanks,  
GoldenSilence
