0
votes

I wanna draw a string to a sprite with a fixed with, and be able to determine the height that the string took up. To give a you a more insight, I'll be creating a simple bubble messaging interface. So I just wanna know how to draw a string to a sprite (or any object you find more suitable), be able to control the width, and get the final height. Thanks

Update: As a matter of fact, I don't necessarily need to be drawing the string. I just need to create that interface.

Update 2: I tried creating a textfield dynamically, but the problem is that I have no idea how to determine the height of it!

1
I found the solution. I just used the textHeight property of the text field. :-D I will add it as an answer in 7 hours.Milad.Nozari

1 Answers

0
votes

Consider this sample :

var sp:Sprite = new Sprite();
var tf:TextField= new TextField();

sp.addChild(tf);

tf.multiline = true;
tf.text = "line 1 \n line 2 \n line 3";

trace(tf.textWidth); 
trace(tf.textHeight);

You should be able to use the height & width of the textbox, to re size the outer sprite.