user1982108
user1982108

Reputation: 35

displaying player lives/text Flash game CS6 AS3

I am coding a flash game using AS3 where the player begins with 3 lives, I want this to be displayed on the screen however it only displays the first letter "L" and no number(int Lives)

here is the relevent code (snippets)

I have a blank textbox with the name txtLives

var lives:int = 3;

txtLives.addEventListener(Event.ENTER_FRAME, updateTextFields);

function updateTextFields(event:Event):void{
 var lives:int = 3;
 var str:String = "Lives ";
 txtLives.text = str + String(lives);
 }

Any help would be great appreciated. Thanks

Upvotes: 1

Views: 769

Answers (3)

FlashGameProgrammer
FlashGameProgrammer

Reputation: 11

Lol if the trick by the guy above don't work then try to extend your text box.

Upvotes: 0

abnvp
abnvp

Reputation: 1027

Or you can enable the usage of device fonts.

use device fonts

Select the "Use Device fonts" and your code should work as expected.

Upvotes: 0

ToddBFisher
ToddBFisher

Reputation: 11610

Make sure your font is embedded on the text field by selecting the text field, then on the properties tab in the character section press the "Embed ..." button. Verify that the character sets you want are all checked.

enter image description here

Also in your function you can simplify it to:

function updateTextFields(event:Event):void
{
     txtLives.text = "Lives " + lives;
}

Upvotes: 3

Related Questions