textflow removes empty spans
I create three unique spanelement's and put them into a paragraphelement in a textflow that's a textarea. The first and last span have text in them, but the middle on has no text as it's a placeholder that will have text set later on.
Flex then helpfully removes all the empty span's - even unique one's - including the placeholder.
Then later on I put text in the placeholder - which is no longer there. No text appears in the textbox and the placeholder doesn't return.
Does anyone have a solution for this? Any help would be much appreciated.
here's some code to demonstrate the issue:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import flashx.textLayout.elements.DivElement;
import flashx.textLayout.elements.ParagraphElement;
import flashx.textLayout.elements.SpanElement;
import mx.controls.Alert;
import org.osmf.image.ImageElement;
import spark.utils.TextFlowUtil;
private var para:ParagraphElement = new ParagraphElement();
private var inc:int = 0;
private var span:SpanElement = new SpanElement;
private var span2:SpanElement = new SpanElement;
private var span3:SpanElement = new SpanElement;
protected function button1_clickHandler(event:MouseEvent):void
{
inc++;
span.id=inc.toString();
span.text="hello";
inc++;
span2.text = "";
span2.id=inc.toString();
inc++;
span3.id=inc.toString();
span3.text="hello2";
textArea.textFlow.replaceChildren(0,textArea.textFlow.numChildren,para);
para.addChild(span);
para.addChild(span2);
para.addChild(span3);
Alert.show(TextFlowUtil.export(textArea.textFlow));
}
protected function button2_clickHandler(event:MouseEvent):void
{
span.text = "changed";
span2.text = "dude where's my placeholder?";
Alert.show(TextFlowUtil.export(textArea.textFlow));
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:TextArea id="textArea" right="10" left="10" top="10" bottom="68"/>
<s:Button label="1) Create Text and Respond Immediately" bottom="39" click="button1_clickHandler(event)" horizontalCenter="0"/>
<s:Button label="2) Changed Placeholder and Respond" bottom="10" click="button2_clickHandler(event)" horizontalCenter="0"/>
</s:WindowedApplication>
