Hello Glen,

On Fri, Oct 9, 2009 at 2:51 PM, Glen Pike <g...@engineeredarts.co.uk> wrote:
>   You can get the text metrics - |flash.text.TextField.getLineMetrics()|
>
>   Have a look in the docs about this class it's quite useful.  Watch out for
> the obligatory 2px gutter around your text..

> Alexander Farber wrote:
>> (my code available at http://pastebin.com/m6d9f4087 )

thank you, I've changed my code to:

                public function set text(str:String):void {
                        _tf.x = PADDING + Util.randRange(10, 40);
                        _tf.y = PADDING + Util.randRange(10, 40);
                        _tf.width = W;
                        _tf.text = str;

                        if (1 == _tf.numLines) {
                                var metrics:TextLineMetrics =
_tf.getLineMetrics(0);
                                // add TextField gutter on both side
                                _tf.width = metrics.width + 2 * 2;
                        }
                       ......
                }

But that 2 * 2 seems to be not enough,
because the TextField breaks my line in two
after I set its width to metrics.width + 2 * 2.

There are probably additional margins
at left and right sides?

Regards
Alex
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to