Skip to main content
Inspiring
September 1, 2009
Answered

different result by textLayout.swc version.

  • September 1, 2009
  • 1 reply
  • 1683 views

Hi

I wrote simple code by using TLF.
It generated three text box with different textAlign.
But, the result of the same code is different by the textLayout.swc version.

Why is the result different?

Tried textLayout.swc is bundled with...
Flex 4 SDK_4.0.0.7219
Flex 4 SDK_4.0.0.9437

OS: WinXP SP2
SDK: ver 3.4
Tool: Flex Builder 3

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
      creationComplete="init()">
     <mx:Script>
          <![CDATA[
               import flashx.textLayout.formats.TextLayoutFormat;
               import flashx.textLayout.container.ContainerController;
               import flashx.textLayout.elements.SpanElement;
               import flashx.textLayout.elements.ParagraphElement;
               import flashx.textLayout.elements.TextFlow;
               import flashx.textLayout.elements.Configuration;
              
               private function init():void
               {
                    var textBox1:Sprite = createTextBox("left");
                    textBox1.x = 300;
                    textBox1.y = 100;
                    this.rawChildren.addChild(textBox1);
                   
                    var textBox2:Sprite = createTextBox("center");
                    textBox2.x = 300;
                    textBox2.y = 250;
                    this.rawChildren.addChild(textBox2);
                   
                    var textBox3:Sprite = createTextBox("right");
                    textBox3.x = 300;
                    textBox3.y = 400;
                    this.rawChildren.addChild(textBox3);
               }
              
               private function createTextBox(value:String):Sprite
               {
                    var rect:Rectangle = new Rectangle(0,0,300,100);
                   
                    var sprite:Sprite = new Sprite();
                     sprite.graphics.lineStyle (1, 0x000000, 1.0);
                    sprite.graphics.beginFill (0xFF0000, 1.0);
                    sprite.graphics.drawRect  (rect.x, rect.y , rect.width , rect.height);
                   
                    var tlFormat:TextLayoutFormat = new TextLayoutFormat();
                    tlFormat.textAlign = value;
                    tlFormat.color = 0x000000;
                    tlFormat.fontSize = 50;
                   
                    var config:Configuration = new Configuration();
                    config.textFlowInitialFormat = tlFormat;
                   
                    var textFlow:TextFlow = new TextFlow(config);
                   
                    var p:ParagraphElement = new ParagraphElement();
                    var s:SpanElement = new SpanElement();
                    s.text = value;
                    p.addChild(s);
                    textFlow.addChild(p);
                   
                    textFlow.flowComposer.addController(new ContainerController(sprite, rect.width,rect.height));
                   
                    textFlow.flowComposer.updateAllControllers();
                   
                    return sprite;
               }
              
          ]]>
     </mx:Script>
</mx:Application>

textLayout.swc is bundled with  SDK_4.0.0.7219

textLayout.swc is bundled with SDK_4.0.0.9437

4007219.jpg4009437.jpg
This topic has been closed for replies.
Adobe Employee
September 1, 2009

Not sure what happened.  I tried your example with the current TLF code and it rendered as in example (a).  That's what I would expect.

Richard

Adobe Employee
September 1, 2009

Actually I believe I recall the bug here.  The content is getting scrolled to the left.

Richard