Skip to main content
Known Participant
May 17, 2011
Question

textLayout error 1009

  • May 17, 2011
  • 1 reply
  • 1248 views

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>

This topic has been closed for replies.

1 reply

Adobe Employee
May 17, 2011

It's the same bug as http://forums.adobe.com/thread/851475?tstart=0. It has already been fixed by us. And it's a pretty big fix. Pls wait for flex team's reply.

Known Participant
May 17, 2011

yeah ,I've already knew it's a bug but I am seeking for some workaround, cuz my project was relaying on this...

so should I wait for the next release?

Inspiring
May 18, 2011

A workaround I used for the sake of testing other stuff was to add two invisible 1px x 1px Inline Graphics to each Paragraph.  The assumption being that the bug is triggered when a TextFlow has only one image in it and that image is about to be cleaned up because it is not rendered in the current container.

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Update: This "work around" does not work. Sorry.