动态翻转 TLF 文本字段上的自动换行属性

发布于 2024-10-22 14:04:11 字数 817 浏览 2 评论 0原文

我正在使用 Flash CS5 和 ActionScript 3。

我需要动态(响应事件)将 TLFTextField 的 wordWrap 属性从 true 翻转为 false,反之亦然。我让它与旧的 TextField 类一起工作,但我无法让它与 TLF 一起工作。

我声明我的字段并像这样设置它,将 wordWrap 设置为 true:

this.field = new TLFTextField;
field.multiline = true;
field.wordWrap = true;
field.autoSize = TextFieldAutoSize.LEFT;

field.tlfMarkup = my_content;

this.addChild(field);
var myTextFlow:TextFlow = field.textFlow;
myTextFlow.hostFormat = format; //format is a TextLayoutFormat declared earlier
myTextFlow.flowComposer.updateAllControllers();

要更改自动换行,我尝试了以下操作:

field.wordWrap = false;
field.multiline = false;
var myTextFlow:TextFlow = field.textFlow;
myTextFlow.flowComposer.updateAllControllers();

但这没有效果 - 文本保持换行。谁能告诉我我错过了什么?

预先感谢,

阿曼达

I am using Flash CS5 and ActionScript 3.

I need to dynamically (in response to an event) flip the wordWrap property of a TLFTextField from true to false and vice versa. I had it working with the old TextField class, but I I can't get it to work with TLF.

I declare my field and set it up like so, with wordWrap set to true:

this.field = new TLFTextField;
field.multiline = true;
field.wordWrap = true;
field.autoSize = TextFieldAutoSize.LEFT;

field.tlfMarkup = my_content;

this.addChild(field);
var myTextFlow:TextFlow = field.textFlow;
myTextFlow.hostFormat = format; //format is a TextLayoutFormat declared earlier
myTextFlow.flowComposer.updateAllControllers();

To change the word wrapping, I've tried the following:

field.wordWrap = false;
field.multiline = false;
var myTextFlow:TextFlow = field.textFlow;
myTextFlow.flowComposer.updateAllControllers();

But this has no effect - the text stays wrapped. Can anyone tell me what I'm missing?

Thanks in advance,

Amanda

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一生独一 2024-10-29 14:04:11

要将自动换行更改为 false,必须设置文本。 (我需要大约半个小时才能让它工作!)

field.wordWrap = false;
trace(field.wordWrap); // will echo true

以下内容应该可以工作:

if(field.text == ""){

  field.text = "a";
  field.wordWrap = false;
  field.text = "";

} else {

  field.wordWrap = false;

}

trace(field.wordWrap); // should echo false

to change wordwrap to false, there has to be text set. ( i needed about half an hour to get it working!)

field.wordWrap = false;
trace(field.wordWrap); // will echo true

this following should work:

if(field.text == ""){

  field.text = "a";
  field.wordWrap = false;
  field.text = "";

} else {

  field.wordWrap = false;

}

trace(field.wordWrap); // should echo false
若无相欠,怎会相见 2024-10-29 14:04:11

首先,你尝试过:
this.field = new TLFTextField();

您没有括号。

至少值得一看。 (而且我相信目前这是测试版,因此可能存在错误?)

最后,您可能会考虑在不使用 AutoSize 的情况下进行测试...有时会导致问题。

抱歉,我无法为您提供更准确的解决方案。

First off, have you tried:
this.field = new TLFTextField();

You didn't have the parenthesis.

At least worth a look at. (Also I believe this is Beta currently so there is a possibility of a bug?)

Finally, you might consider testing this without the AutoSize... sometimes causes problems.

Sorry that I can't be a little more helpful with an exact solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文