无闪动动态在TextArea中添加HTML文本

首先引用以下TextArea的帮助文档http://docs.huihoo.com/flex/4/spark/components/TextArea.html

TextArea is a text-entry control that lets users enter and edit multiple lines of richly formatted text. It can display horizontal and vertical scrollbars for scrolling through the text and supports vertical scrolling with the mouse wheel. 

 

伴随着Flex4的出现,Spark的全新改版,在使用TextArea的时候,发现HTMLText标签不见了。

由此产生了困惑,HTMLText没有了,那S:TextArea岂不是反而退步了么,但我相信Adobe不会这么傻,不进步反而后退。

 

S:TextArea要想显示HTMLText要简单也会很简单就这样就ok

textArea.textFlow = TextConverter.importToFlow(string, TextConverter.TEXT_FIELD_HTML_FORMAT); 

string还能实现动态绑定。

 

可如果你按这样的方式去做,你会发现每改变以下string的值,整个textArea都在刷新,如果仅仅是想在string后面再加内容,只需要追加显示而不是全部刷新这样的方式就显得很不爽了。

 

如下方式完美解决:动态增加string,而不照成任何的闪动

 

public function addParagraphElement(tf:TextFlow,content:String,color:uint=0x333333,startIndent:int = 20):void

{

var p:ParagraphElement = new ParagraphElement;

p.paragraphStartIndent = startIndent;

var se:SpanElement=new SpanElement();

se.text = content;

se.color = color;

p.addChild(se);

tf.addChild(p);

tf.flowComposer.updateAllControllers();

 

 

<s:TextArea id="textArea"

width="100%"  editable="false" height="100%">

<s:textFlow>

<s:TextFlow id="tf" updateComplete="area.textDisplay.verticalScrollPosition=area.textDisplay.contentHeight">

</s:TextFlow>

</s:textFlow>

</s:TextArea>

 

 

 

 

 

 

 

 

 

 

转载于:https://www.cnblogs.com/anfeind/archive/2010/11/15/1877688.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值