0

Question is about Flex4 Text Engine:

I want to 1) append HTML text to textArea text1

I can load text like:

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);

But I have no idea how to appen new text !

2) add an image to textArea

All this in the the new TLF : any idea ?

Regards

yarek
  • 11,278
  • 30
  • 120
  • 219

1 Answers1

1

This sets text plus loads an image, then uses a timer to append text every 5-seconds:

<?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>
Jason Sturges
  • 15,855
  • 14
  • 59
  • 80
  • that's almost good: Trouble is text is blinking: it seems it is not appened but reloaded totally – yarek Oct 24 '11 at 21:47
  • Yes, that's frustrating. While searching I found a similar request to yours here: http://stackoverflow.com/questions/6024012/append-a-flow-to-an-existing-textflow - perhaps is more inline with what you're looking for. – Jason Sturges Oct 24 '11 at 22:04