0

即使 wordWrap 属性设置为 true,我也遇到了 TextField 组件在每行末尾剪切单词的问题。

例子:

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

如何解决这个问题?谢谢

编辑1:

我有一个使用参数 .size=20 应用的 textFormat。

编辑2:

以下是相关代码:

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..";
4

2 回答 2

1

你可以用右边距解决这个问题。您需要多少边距取决于字体大小。你必须测试一下。

只需将 x px 宽度添加到您的 textField

tf.width += 10;

并在 tf 中添加相同数量的右边距:

tf.rightMargin = 10;

现在没有话被删减

于 2014-05-02T09:30:55.753 回答
0

这个应用程序适合我。它和你的一样,除了我在应用程序中指定没有缩放,并且对齐为左上角。如果我不这样做,文本将无法正确呈现。

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);
        }
    }
}
于 2012-07-27T18:18:02.157 回答