zoukankan      html  css  js  c++  java
  • 无闪动动态在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>

  • 相关阅读:
    IE、FF、Chrome浏览器中的JS差异介绍
    防止 jsp被sql注入的五种方法
    读取Excel数据到Table表中
    C#获取IP地址
    JavaScript之web通信
    Unity使用 转载
    EF5 通用数据层 增删改查操作,泛型类
    Entity FrameWork 5 增删改查 & 直接调用sql语句
    asp.net重启web应用程序域
    .net创建activex实现摄像头拍照
  • 原文地址:https://www.cnblogs.com/anfeind/p/1877688.html
Copyright © 2011-2022 走看看