In ActionScript, the most natural way to handle this, I think, would be to use a container like Sprite and draw using a graphics object and / or add other displayed objects as children. Then you can take your “snapshot” when / if necessary to get pixel data.
To add text, creating a TextField is the easiest option.
Anyway, you could write a little function that does this on an existing BitmapData if you want. Here is a sketch of how to write such a function:
function drawString(target:BitmapData,text:String,x:Number,y:Number):void { var tf:TextField = new TextField(); tf.text = text; var bmd:BitmapData = new BitmapData(tf.width,tf.height); bmd.draw(tf); var mat:Matrix = new Matrix(); mat.translate(x,y); target.draw(bmd,mat); bmd.dispose(); }
Juan Pablo Califano
source share