Reputation: 2465
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..";
Upvotes: 0
Views: 3300
Reputation: 43
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
Upvotes: 1
Reputation: 18194
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);
}
}
}
Upvotes: 0