0

I'm having a problem with TextField component cutting the words at the very end of every line, even though the wordWrap property is set to true.

example:

This is a test te
xt, this is a tes
t text. This is a
test text.

How to fix this? thanks

EDIT 1:

I have a textFormat applied with parameter .size=20.

EDIT 2:

Here is the relevant code:

var tx:TextField = new TextField();
var tf:TextFormat = new TextFormat();

tf.size = 18;

tx.defaultTextFormat = tf;      
tx.autoSize = TextFieldAutoSize.CENTER;
tx.multiline = true;
tx.wordWrap = true;
tx.width = 835;

tx.text = "Long text..";
astralmaster
  • 2,344
  • 11
  • 50
  • 84
  • You might want to show your code. In the simplest case I see word wrapping is happening between words (as expected), not in the middle of them as in your example. – Sunil D. Jul 27 '12 at 17:37

2 Answers2

1

you can solve that problem with a right margin. how much margon you need depends on font size. you have to test that.

Just add x px width to your textField

tf.width += 10;

and add a right Margin of the same amount to the tf:

tf.rightMargin = 10;

now no words are cut any more

user3359433
  • 43
  • 1
  • 7
  • 1
    Please explain better with more words. – Andrei May 02 '14 at 09:50
  • Yes, this worked for me. I had a font with very far reaching curly lines coming off capital letter that would look masked / cut off by some kind of letter bounding box. Adding right and left margins to the TextFormat at different sizes for different fonts did the trick. – OG Sean Jul 19 '14 at 02:16
0

This app works for me. It's same as yours, except that I've specified no scaling in the app, and the alignment as top-left. If I don't do those, the text is not rendered properly.

package
{
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;

    public class Woot extends Sprite
    {
        public function Woot()
        {
            super();
            stage.align=StageAlign.TOP_LEFT;
            stage.scaleMode=StageScaleMode.NO_SCALE;
            var tx:TextField = new TextField();
            var tf:TextFormat = new TextFormat();
            tf.size = 18;
            tx.defaultTextFormat = tf;
            tx.autoSize = TextFieldAutoSize.CENTER;
            tx.multiline = true;
            tx.wordWrap = true;
            tx.width = 835;
            tx.text = "this is some long text. this is some long text. this is some long text.this is some long text. this is some long text. this is some long text.this is some long text. this is some long text. this is some long text.this is some long text. this is some long text. this is some long text.this is some long text. this is some long text. this is some long text.this is some long text. this is some long text. this is some long text.this is some long text. this is some long text. this is some long text.this is some long text. this is some long text. this is some long text.this is some long text. this is some long text. this is some long text.this is some long text. this is some long text. this is some long text.this is some long text. this is some long text. this is some long text.this is some long text. this is some long text. this is some long text.this is some long text. this is some long text. this is some long text.";
            addChild(tx);
        }
    }
}
Sunil D.
  • 17,983
  • 6
  • 53
  • 65