00:00
00:00
Newgrounds Background Image Theme

GeorgiaC-1811 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

as3 help with variables

483 Views | 2 Replies
New Topic Respond to this Topic

as3 help with variables 2012-01-15 20:58:14


how do you make a score go variable go into text.

//for example this is the score variable
var score = 0
//then the even listener
addEventListener(Event.ENTER_FRAME,oranges)
function oranges(e:Event){
score_text.text = score
}

but the text disappears right away, can anyone offer a solution?

Response to as3 help with variables 2012-01-15 21:22:30


Just quickly tested it and the only thing that I see that would cause that is not having the Font embedded. Embed the font you're using for the dynamic text box or change the AA to "Use Device Fonts".


BBS Signature

Response to as3 help with variables 2012-01-15 21:40:57


You don't should create an event listener for the oranges, and then for apples and then for the pineapples's truck but an only unique event which call every function so you can do oranges() inside it for example.

You also must output the text as a String and not int.

Like this:

var score:int=0;

function oranges():void
{
          score++;
          oranges_txt.text=String(score);
}

function evt(e:Event):void
{
         oranges();
}

addEventListener(Event.ENTER_FRAME,evt);