Skip to main content
Participant
May 30, 2013
Question

Hey, im having some trouble with my code

  • May 30, 2013
  • 1 reply
  • 604 views

I'm trying to make a object be worth points. Here is the code im using, but it doesnt make the score increase, it just makes the 0 vanish after clicking on the item. Then you click on the item again and it says 00, then nothing, then 0 and repeat. Any ideas?

----------------------------------------------------

var currentScore:int;

init(); // this line goes directly beneath the variables

function init():void{ // call once to set everything up

     currentScore = 0; //start with 0 score

     MoneyBtn.addEventListener(MouseEvent.CLICK, addScore ); // clicking on +1

     

            }

function updateScoreText():void

{

     scoretxt.text = (""+ currentScore); // set the text property of the txtScore

     trace("Score text updated");

     }

     updateScoreText(); // finally, update the text field

          

           function addScore(e:MouseEvent):void{

     currentScore += 25; // add points to the score

     updateScoreText(); // update the textfield

}

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
May 30, 2013

there's no problem with the code you showed.  in particular, that code would not cause the problem you are seeing.

Participant
May 30, 2013

then what is the problem. instead of adding 25 points, it just changes the score to blank, then 00, then blank.

Participant
May 30, 2013

Fixed it. the text wasnt embeded. FML lol