Gha*_*nPL 9 apache-flex text shape displayobject actionscript-3
有没有办法只使用ActionScript在DisplayObject或Shape中绘制文本?我可以在网上找到的唯一方法是创建一个TextField,但我不能将TF添加到DisplayObject或Shape.
编辑:
解决了感谢viatropos.
对于任何有兴趣的人:
DisplayObject工具IBitmapDrawable能够作为参数传递给传递draw一个的功能BitmapData对象,然后可以使用绘制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();
好问题.这超出了我需要做的任何事情,但我想我知道该怎么做.
Shape扩展DisplayObject,但不扩展DisplayObjectContainer,因此您无法向其添加任何内容.但它确实具有graphics属性,因此您可以将内容绘制到其中.我能想到的最好的方法是获取TextField的Bitmap快照,并将其绘制到Shape中.我知道这是Degrafa为他们的RasterText所做的事情(查看源代码,这真的很有帮助).
如果你将Shape改为Sprite,那就容易多了.Sprite扩展了DisplayObjectContainer,因此您可以在那里添加TextField.
希望有所帮助,兰斯
| 归档时间: | 
 | 
| 查看次数: | 8724 次 | 
| 最近记录: |