AS3 - Function not working always

I have a button that opens up a shop. This shop has some text in it that displays the cash information for your player. When I create the shop inside a .as class I make the text display. It will work if I call the function when I click a shop button, but if I call it when I first create the shop, it doesn't work. Here is my code and please explain why this might not work.

public function UGShop(){
updateStats();
}

public function updateStats(){
    CashTXT.text = String("$ " + cashamount);
}
}

My cash is already in my shop. This is just a portion of my code.

Upvotes: 0

Views: 170

Answers (1)

Daniel MesSer
Daniel MesSer

Reputation: 1181

  1. cashtxt isn't created or is not on stage.
  2. cashamount has no value

If it's something else, you didn't supply any info for it

If you run into these things often, try looking into Monster Debugger, it can tell you the state of any object on stage.

Upvotes: 1

Related Questions