AS3 - Score not updating

I have set this that when the player hits the coin, a point should be added (in fact I can see it is added trough the trace) but the textField is not updating. Did I do somthing wrong? Btw the text field is already Dynamic and I have incorporated the font.

coin.addEventListener(Event.ENTER_FRAME, addScore);

var score:Number = 0;
scoreCounter.text = "0";

function addScore (e) {
if (objPlayer.hitTestObject(coin)) {
updateScore();
trace("Score: " + score);
coin.x = - 1 - coin.width/2;
    }
}
 function updateScore() {
    score++;
    scoreCounter.text = String(score);
}

I've also tried with this approach:

coin.addEventListener(Event.ENTER_FRAME, addScore);

var score:int = 0;

function addScore (e) {
if (objPlayer.hitTestObject(coin)) {
    score++;
    updateScore();
    trace("Score: " + score);
    coin.x = - 1 - coin.width/2;
}
}
function updateScore():void {
 scoreCounter.text = ("Score: " + score);
}

Answers


Looks like your code is fine. Your using a specific font (Arial), so you need to embed that font. Or, use the _sans font instead. Then it should work for you.


Need Your Help

Add Unique Links to all d3.js Data Points in Graph

javascript svg d3.js nvd3.js

I'm using nvd3.js to create a line graph that displays ratings that I have calculated over time. I have more information for each individual data point (rating) and would like to have each data poi...

Equivalent Ruby .times in Coffeescript

ruby coffeescript

What is the most concise equivalent Coffeescript to the following: