【问题标题】:flex4 textArea HTMLflex4 textArea HTML
【发布时间】:2011-10-24 17:18:54
【问题描述】:

关于 Flex4 文本引擎的问题:

我想 1) 将 HTML 文本附加到 textArea text1

我可以加载如下文本:

var s:String='<p fontSize="12">TextArea with<span fontWeight="bold">TLF</span> block</p>';
text1.textFlow = TextFlowUtil.importFromString(text1.text + s, TextConverter .TEXT_FIELD_HTML_FORMAT);

但我不知道如何添加新文本!

2) 将图片添加到 textArea

所有这些都在新的 TLF 中:有什么想法吗?

问候

【问题讨论】:

    标签: apache-flex flex4 flex4.5


    【解决方案1】:

    这会设置文本并加载图像,然后使用计时器每 5 秒添加一次文本:

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   minWidth="955"
                   minHeight="600"
                   creationComplete="creationCompleteHandler(event)">
    
        <fx:Script>
            <![CDATA[
                import flashx.textLayout.conversion.TextConverter;
                import flashx.textLayout.elements.TextFlow;
    
                import mx.events.FlexEvent;
    
                [Bindable]
                private var text:String =
                    "This text can be appended to.<br />" +
                    "<br />" +
                    "<img src=\"http://www.google.com/intl/en_com/images/srpr/logo3w.png\" />";
    
    
                private var timer:Timer;
    
                protected function creationCompleteHandler(event:FlexEvent):void
                {
                    // 5-seconds later, append text
                    timer = new Timer(5000);
                    timer.addEventListener(TimerEvent.TIMER, timerHandler);
                    timer.start();
                }
    
                protected function timerHandler(event:TimerEvent):void
                {
                    text += "This is the appended text.<br />";
                }
            ]]>
        </fx:Script>
    
        <s:RichEditableText editable="false"
                            selectable="true"
                            textFlow="{TextConverter.importToFlow(text, TextConverter.TEXT_FIELD_HTML_FORMAT)}"
                            buttonMode="true"
                            width="100%"
                            height="100%" />
    
    </s:Application>
    

    【讨论】:

    • 差不多好了:问题是文本在闪烁:似乎它没有被添加,而是完全重新加载
    • 是的,这令人沮丧。在搜索时,我在这里找到了与您类似的请求:stackoverflow.com/questions/6024012/… - 可能更符合您的要求。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-29
    • 2011-04-10
    • 1970-01-01
    • 2014-07-27
    • 2011-04-30
    相关资源
    最近更新 更多