动态翻转 TLF 文本字段上的自动换行属性
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要将自动换行更改为 false,必须设置文本。 (我需要大约半个小时才能让它工作!)
以下内容应该可以工作:
to change wordwrap to false, there has to be text set. ( i needed about half an hour to get it working!)
this following should work:
首先,你尝试过:
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.