Skip navigation
Currently Being Moderated

How to manage linked containers with different Widths?

Sep 22, 2010 5:18 AM

I have two linked containers. When I update the compositionSize on one of them, they both change. They share the same textFlow, so my code is simply:

 

containerController.setCompositionSize(this.width, this.height);

textFlow.flowComposer.updateAllControllers();

 

- I would expect this only to update the width of the specified controller/container pair, but it operates on both of them.

 

What am I doing wrong?

 

Many thanks in advance.

 

Jude Fisher / JcFx.Eu

 
Replies
  • Currently Being Moderated
    Sep 22, 2010 8:13 PM   in reply to JcFx.Eu

    Are you sure you are setting the size on only one? Can you send some code that shows this? What version of TLF are you using?

     

    - robin

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 28, 2010 12:27 PM   in reply to JcFx.Eu

    I wrote a small app that shows the functionality, and it seems to be working for me. Can you try this and take a look and see what you're doing differently?

     

    Thanks!

     

    package {
       
        import flash.display.Sprite;
        import flash.geom.Rectangle;
       
        import flashx.textLayout.container.ContainerController;
        import flashx.textLayout.conversion.TextConverter;
        import flashx.textLayout.elements.*;
        import flashx.textLayout.formats.TextLayoutFormat;
       
        [SWF(width="600", height="400")]
        public class Bug extends Sprite
        {
            private var textFlow:TextFlow;
           
            public function Bug()
            {
                const markup:String = '<TextFlow xmlns="http://ns.adobe.com/textLayout/2008" textAlign="start" fontFamily="Minion Pro" fontSize="16">I. Down the Rabbit-Hole<p textAlign="center" fontSize="24">Chapter I</p>' +
                    '<p textAlign="center" fontSize="24">Down the Rabbit-Hole</p>' +
                    '<p>Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, “and what is the use of a book,” thought Alice “without pictures or conversation?”</p>' +
                    '<p>So she was considering in her own mind (as well as she could, for the hot day made her feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her.</p> ' +
                    '</TextFlow>';
                textFlow = TextConverter.importToFlow(markup, TextConverter.TEXT_LAYOUT_FORMAT);
               
                var firstSprite:Sprite = new Sprite();
                addChild(firstSprite);
                var firstController:ContainerController = new ContainerController(firstSprite, 200, 300);
                textFlow.flowComposer.addController(firstController);
                var secondSprite:Sprite = new Sprite();
                secondSprite.x = 250;
                addChild(secondSprite);
                var secondController:ContainerController = new ContainerController(secondSprite, 200, 300);
                textFlow.flowComposer.addController(secondController);
                textFlow.flowComposer.updateAllControllers();
                traceController(firstController);
                traceController(secondController);
               
                firstController.setCompositionSize(100, firstController.compositionHeight);
                traceController(firstController);
                traceController(secondController);
                textFlow.flowComposer.updateAllControllers();

     

            }
           
            private function traceController(controller:ContainerController):void
            {
                trace("Controller size", controller.compositionWidth, ",", controller.compositionHeight);
            }

     

        }
       
    }

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points