Take the 2-minute tour ×

I'm having a bit of confusion about how to render text in a pure AS3 project. There are classes like flash.text.StaticText but these are designer-only, you can't create them in code. I was half-expecting the Graphics class to have text-rendering options but alas, no.

Specifically I was going to add a label above each player's sprite with their name, health %, etc. So I expected to add a child text-element or draw text using Graphics in some way... it's read-only and should not support user-input, I just want to draw text on-screen.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

You can use TextField class for this. Please check the reference. All fields and methods are self explanatory.

A possible example.

var myField:TextField = new TextField();
myField.text = "my text";
myField.x = 200;
myField.y = 200;
addChild(myField); // assuming you are in a container class 
share|improve this answer
Don't forget selectable = false, it is commonly overlooked. –  alxx Feb 4 '11 at 14:38
add comment

Your Answer


