Spark TextArea或RichText自动调整大小 [英] Spark TextArea or RichText autosize

查看:169
本文介绍了Spark TextArea或RichText自动调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



使用TextFields,我们可以使用TextFields在过去,您可以将TextField设置为一定的宽度,将wordWrap设置为true,然后根据您添加的文本更改高度的文本框。



现在我试图用Spark TextArea或RichText做这个。



我试过这个HeightInLines = NAN,但似乎已经过期了。 >

我也试过这个例程:

  var totalHeight:uint = 10; 
this.validateNow();
var noOfLines:int = this.mx_internal :: getTextField()。numLines;
for(var i:int = 0; i< noOfLines; i ++)
{
var textLineHeight:int =
this.mx_internal :: getTextField()。getLineMetrics(i )。高度;
totalHeight + = textLineHeight;
}
this.height = totalHeight;

但是mx_internal不在Spark组件中。



我试图用AS3而不是MXML来做到这一点。如果有人有任何建议或链接,可以帮助我解决使用AS3,我真的很感激。

解决方案

整个下午都在苦苦挣扎。但它看起来像RichEditableText组件将autosize,如果您设置其宽度,并保持其高度不确定。


I have done lots of searching on this subject, but it seems what I am finding is either out of date or just does not seem to work.

With TextFields in the past, you could set the TextField to a certain width, set wordWrap to true and you would end up with a textfield that changed height according to the text you added.

Now I am trying to do this with either the Spark TextArea or RichText.

I tried this HeightInLines = NAN, but that seems to be out of date.

I also tried this routine:

var totalHeight:uint = 10;
this.validateNow();
var noOfLines:int = this.mx_internal::getTextField().numLines;
for (var i:int = 0; i < noOfLines; i++) 
{
     var textLineHeight:int = 
                     this.mx_internal::getTextField().getLineMetrics(i).height;
     totalHeight += textLineHeight;
}
this.height = totalHeight;

But the mx_internal is not in the Spark components.

I am trying to do this with AS3, not MXML. If anyone has any suggestions or links that could help me figure this out using AS3, I'd really appreciate it.

解决方案

Been struggling with this all afternoon. But it looks like the RichEditableText component will autosize if you set its width and leave its height undefined.

这篇关于Spark TextArea或RichText自动调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆