0 Replies Latest reply on Jun 27, 2010 3:39 PM by hminsky

    How to efficiently append text to a TextFlow?

    hminsky

      I have a TextFlow multiline text area that I am managing with a TextContainerManager.

       

      I want to append some HTML formatted text to the end of the textFlow.

       

      I found some code which copies the FlowElements out of a new TextFlow, so I wrote an appendText method like this

       

              public function appendText( t:String ):void {

                  var aflow:TextFlow = TextConverter.importToFlow(t,
                                                                  html ? TextConverter.TEXT_FIELD_HTML_FORMAT : TextConverter.PLAIN_TEXT_FORMAT,
                                                                  config);

       

                  while (aflow.numChildren) {
                      textFlow.addChild(aflow.getChildAt(0));
                  }
                  textFlow.flowComposer.updateAllControllers();

      }

       

      This works, except for one issue which is that the new TextFlow contents are always in a new Paragraph, i.e., there is a linebreak

      between the last char of the pre-existing text, and the first char of my new text string.

       

      Is there any way to get the new textFlow's contents to go into the last SPAN or P or whatever the FlowElement is in the

      main textflow, so that I don't get a forced linebreak ?