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.
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