0 Replies Latest reply on Jul 26, 2011 2:09 PM by DilipShah

    TextFlowUtil's export method is not setting whiteSpaceCollapse to "collapse"

    DilipShah Level 1
      I'm trying to convert some 'regular/normal' text with  embedded images to TextFlow format. During the conversion process, I want the  final TextFlow formatted text to have its whiteSpaceCollapse property as  'collapse'. However, when I user TextFlowUtil's export method,  whiteSpaceCollapse property is set to 'preserve'. What am I doing wrong  here?
      Here is the simple program with trace statement that  shows that the converted text has  whiteSpaceCollapse="preserve" even when the TextFlow object's whiteSpaceCollapse is set to 'collapse': I'm using Flex 4.1 (build 16076).

      <?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="600" minHeight="600"
          creationComplete="application1_creationCompleteHandler(event)"
          >
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
         
          <s:RichText
              width="500"
              textFlow="{textFlow}"
              />
         
          <fx:Script>
              <![CDATA[
                  import flashx.textLayout.conversion.TextConverter;
                  import flashx.textLayout.elements.Configuration;
                  import flashx.textLayout.elements.TextFlow;
                  import flashx.textLayout.formats.TextLayoutFormat;
                  import flashx.textLayout.formats.WhiteSpaceCollapse;
                 
                  import mx.events.FlexEvent;
                 
                  import spark.utils.TextFlowUtil;
                 
                  [Bindable]
                  private var textFlow:TextFlow;
                 
                  protected function application1_creationCompleteHandler(event:FlexEvent):void
                  {
                      var inputString:String =
                          "How come this <img height='95' width='275' source='http://www.google.com/intl/en_com/images/srpr/logo2w.png'/> doesn't work?";
                     
                      var textFlowInitialFormat:TextLayoutFormat = new TextLayoutFormat();
                      textFlowInitialFormat.whiteSpaceCollapse =     flashx.textLayout.formats.WhiteSpaceCollapse.COLLAPSE;
                     
                      var config:Configuration = TextFlow.defaultConfiguration;
                      config.textFlowInitialFormat = textFlowInitialFormat;
                      TextFlow.defaultConfiguration = config;
                     
                      textFlow = TextFlowUtil.importFromString(inputString, WhiteSpaceCollapse.COLLAPSE);
                      textFlow.whiteSpaceCollapse = flashx.textLayout.formats.WhiteSpaceCollapse.COLLAPSE;
                     
                      var outputString:String = TextFlowUtil.export(textFlow).toXMLString();
                     
                      trace(outputString);
                     
                      textFlow =
                          TextConverter.importToFlow(
                              outputString,
                              TextConverter.TEXT_LAYOUT_FORMAT
                          );
                     
                  }
                 
              ]]>
          </fx:Script>
      </s:Application>