textLayout error 1009
Ok,I reproduce it with the code below, replace the 04.swf with any small swf animation is ok
click the button will raise the exception
Is there any workaround ?
<?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" creationComplete="application1_creationCompleteHandler(event)"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="400" minHeight="300" xmlns:local="*"
>
<fx:Script>
<![CDATA[
import flashx.textLayout.elements.InlineGraphicElement;
import flashx.textLayout.elements.ParagraphElement;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.formats.WhiteSpaceCollapse;
import mx.events.FlexEvent;
import spark.utils.TextFlowUtil;
[Bindable]
private var chatTLF:TextFlow;
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
var str:String = "";
var i:int = 30;
while(i>0){
str += i+"\n"
i--;
}
chatTLF = TextFlowUtil.importFromString(str,WhiteSpaceCollapse.PRESERVE);
var p:ParagraphElement = new ParagraphElement();
var graphicElement:InlineGraphicElement = new InlineGraphicElement();
graphicElement.source = "04.swf";
graphicElement.width = 28;
graphicElement.height = 30;
p.addChild(graphicElement);
chatTLF.addChildAt(0,p);
}
protected function chatContentBox_updateCompleteHandler(event:FlexEvent):void
{
callLater(function():void{
scroller.verticalScrollBar.viewport.verticalScrollPosition = scroller.verticalScrollBar.maximum;
})
}
protected function button1_clickHandler(event:MouseEvent):void
{
var tf:TextFlow = TextFlowUtil.importFromString("aaa",WhiteSpaceCollapse.PRESERVE);
for each(var p:ParagraphElement in tf.mxmlChildren){
chatTLF.addChild(p);
}
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Scroller id="scroller" x="10" y="10" width="138" height="226" verticalScrollPolicy="on">
<s:RichEditableText id="chatContentBox" editable="false" focusEnabled="false" updateComplete="chatContentBox_updateCompleteHandler(event)"
textAlign="left" textFlow="{chatTLF}"/>
</s:Scroller >
<s:Button x="62" y="288" click="button1_clickHandler(event)" label="click me"/>
</s:Application>
