The ActionScript used was as follows:
//Tell the counter to start from 0
var score:Number =0
//Shows "Score 0" on stage prior to the object being clicked
scoreText.text="Score "+String(score)
square.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
function fl_MouseClickHandler(event:MouseEvent):void
{
//adds +1 to the variable
score+=1
//To the text box on the stage increases to value without changing the the word "Score"
scoreText.text="Score "+String(score)
//tested whether the function was working
trace("SCORE");
}
The text box on the stage was set to "Classic text" and "Dynamic text" so that the AS was able to change the value within it.
No comments:
Post a Comment