Skip to main content
Participating Frequently
February 16, 2011
Question

Height of selectable text

  • February 16, 2011
  • 1 reply
  • 680 views

Hello,

When I add interactionManager to a TextFlow:

textFlow.interactionManager=new SelectionManager();

height of text is ContainerController.compositionHeight, even when there is only one line of text in a textFlow.

When text isn't selectable, the height is actual height of ContainerController.container - and for me it's perfect.

Problem starts when I put ContainerController.container into another clip - that clip's height is also computed on container.height which provides me unexpected results.

How to avoid it?

This topic has been closed for replies.

1 reply

Adobe Employee
February 17, 2011

There are several different ways to measure the height of the text. If you are looking at the container's height property, that is calculated by the Flash Player based on the DisplayObjects that are in the container. A selectable TextFlow's container has a transparent background that is used so that the container will get mouse clicks for the entire area, not just over the text. This has does, as you point out, change the value of the height property of the container. If you override the ContainerController class with your own version that overrides the attachTranparentBackground() function and returns false, and then use your own ContainerController class when you do the addController call when setting up the TextFlow. But, you will then only get mouse clicks that are directly on the text, and it will ignore clicks that are below the text, in the margin, or between the lines.

So, you could do something like this:

public class NoBackgroundController extends ContainerController

{

     protected function get attachTransparentBackground():Boolean  { return true; }

}

and then when you setup the flow you would do this:

textFlow.flowComposer.addController(new NoBackgroundController(spriteContainer, width, height));

What is going wrong in the MovieClip when you use it?

Thanks,

- robin

Participating Frequently
February 17, 2011

Robin,

Your way actually works. Thank You. Besides that it ignores clicks between the lines - it's ok.

I wonder if there is a way to resize ContainerController after textFlow is created and actual height of text is calculated. I'd just shrink transparent background and problem solved.

Participating Frequently
February 17, 2011

Ok I found solution for adjusting compositionHeight.

in NoBackgroundController which overrides ContainerController I added:

public function get selectableTextHeight():Number

{

     return super.contentHeight;

}

this is for TLF 2.0, for 1.1 I had to add also :

override tlf_internal function get contentHeight():Number

{

     return super.contentHeight;

}

Thank You for suggestion to extend ContainerController