Is there any way to draw text in a DisplayObject or Shape using only ActionScript? The only way I can find on the web is by creating a TextField, but I can't add a TF to a DisplayObject or Shape.
Edit:
Solved thanks to viatropos.
For anyone that's interested:
DisplayObject
implements IBitmapDrawable
which can be passed as an argument to the draw
function of a BitmapData
object, which then can be drawn using graphics.beginBitmapFill
.
var textfield:TextField = new TextField;
textfield.text = "text";
var bitmapdata:BitmapData = new BitmapData(theWidth, theHeight, true, 0x00000000);
bitmapdata.draw(textfield);
graphics.beginBitmapFill(bitmapdata);
graphics.drawRect(0, 0, theWidth, theHeight);
graphics.endFill();