2 Replies Latest reply on Mar 22, 2010 1:49 AM by Mikhail Shevchuk

    TextFlow height and Flex SDK 3.5

    Mikhail Shevchuk

      Hello, forum

       

      Thank you very much for the possibility to use TextFlow in Flex 3. I'm using the technique as Mihai Corlan by doing the following thing:

      There is a TextFlow instance and a ParagraphElement added to it.

      var p : ParagraphElement = new ParagraphElement();
      span.text = 'Disc VERBATIM DVD+RWs 4x Jewel Case 5';
      p.addChild(span);
      _textFlow.addChild(p);

       

      The TextContainer is a Sprite and it is added as canvLabel.rawChildren.addChild(_textContainer); into the Flex Canvas.

      <mx:Canvas id="canvLabel" height="80" width="100%" >
      </mx:Canvas>

       

      What I am trying to implement is to resize the Canvas automatically to fit the TextFlow. How can this be done?

      How can I define the height of the TextFlow that was put into my Canvas and automatically detect the correct height for the Canvas?

      If I set the Canvas height to 100% nothing is showed. I guess in Gumbo the Container is automatically resized due to TextFlow's height but how this can be implemented in Flex 3.5 ?

       

      Thanks in advance,

      Mikhail Shevchuk

        • 1. Re: TextFlow height and Flex SDK 3.5
          Flex harUI Adobe Employee

          You will need to follow the recipe in the "creating custom components"

          chapter in the documentation and use UIComponent instead of a Sprite.

           

          If you get lost, look at the Flex 4 code for help.

          • 2. Re: TextFlow height and Flex SDK 3.5
            Mikhail Shevchuk Level 1

            Well, I can build a textcontainer as a UIComponent, but how can I detect width and height of the TextFlow so I can set appropriate size in measure() method of that UIComponent.

             

            I guess this code should be implemented then in createChildren():

             

            _textFlow.flowComposer.addController(new ContainerController(_textContainer, canvLabel.width, canvLabel.height));

             

            _textContainer will be replaced with 'this', canvLabel.width with this.width, canvLabel.height with height, but how I set the correct size in this UIComponent?

             

            Thanks in advance,

            Mikhail