Be a Supporter!

as3 help with variables

  • 236 Views
  • 2 Replies
New Topic Respond to this Topic
Stefan987654123
Stefan987654123
  • Member since: Dec. 26, 2010
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
as3 help with variables 2012-01-15 20:58:14 Reply

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?

Torrunt
Torrunt
  • Member since: May. 3, 2007
  • Offline.
Forum Stats
Member
Level 22
Programmer
Response to as3 help with variables 2012-01-15 21:22:30 Reply

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
Spysociety
Spysociety
  • Member since: Dec. 30, 2009
  • Offline.
Forum Stats
Member
Level 21
Blank Slate
Response to as3 help with variables 2012-01-15 21:40:57 Reply

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);