Textflow link element doesn't work after append to an existed textflow
It's a strange problem
I have two textflow container : RichEditableText
the first one I new the textflow2 everytime I clicked the button,and append a link returned by getElement
the second one I initially new a textflow and reused it to append new link returned by the same function getElement
but the strange thing is , the first one works just fine ,but the second one 's link seems invalid with no hand cursor nor function
thanks a lot for any clue or comment
<?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="400" minHeight="300">
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Script>
<![CDATA[
import flashx.textLayout.elements.LinkElement;
import flashx.textLayout.elements.ParagraphElement;
import flashx.textLayout.elements.SpanElement;
import flashx.textLayout.elements.TextFlow;
[Bindable] public var textFlow:TextFlow = new TextFlow();
[Bindable] public var textFlow2:TextFlow = new TextFlow();
protected function button1_clickHandler(event:MouseEvent):void
{
textFlow2 = new TextFlow();
textFlow2.addChild(getElement());
textFlow.addChild(getElement());
}
private function getElement():ParagraphElement{
var linkSpan:SpanElement = new SpanElement();
linkSpan.text = "link";
var link:LinkElement = new LinkElement();
link.addChild(linkSpan);
link.href = "event:ok"
var p:ParagraphElement = new ParagraphElement();
p.addChild(link);
return p;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- -->
</fx:Declarations>
<s:RichEditableText editable="false" text="RichText" width="180" height="165" textFlow="{textFlow2}" />
<s:RichEditableText editable="false" x="196" text="RichText" width="180" height="165" textFlow="{textFlow}" />
<s:Button x="116" y="217" label="button" click="button1_clickHandler(event)"/>
</s:Application>
