2011-10-24 56 views
0

問題是關於FLEX4文本引擎:FLEX4 textarea的HTML

我想 1)追加HTML文本到textarea的文本1

我可以加載文本,如:

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)在新的TLF圖像添加到textarea的

這一切:什麼想法?

問候

回答

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> 
+0

這幾乎好: 麻煩的是文字閃爍:現在看來,這沒有被加載,但完全被重新加載 – yarek

+0

是的,這令人沮喪。在搜索過程中,我在這裏發現了一個類似的請求:http://stackoverflow.com/questions/6024012/append-a-flow-to-an-existing-textflow - 也許更符合您的要求。 –