是否有任何方法仅使用ActionScript在DisplayObject或Shape中绘制文本?我可以在网上找到的唯一方法是创建一个TextField,但我不能将TF添加到DisplayObject或Shape。在ActionScript 3中绘制形状文字
编辑:
解决由于viatropos。
对于任何这是感兴趣的:其可以作为参数传递给一个BitmapData
对象,然后可以使用graphics.beginBitmapFill
绘制的draw
功能被传递
DisplayObject
实现IBitmapDrawable
。
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();