Skip to main content
Participant
September 9, 2010
Question

Problem in Setting CompositionHeight

  • September 9, 2010
  • 3 replies
  • 809 views

I was using TLF in the webgame in these days.

There is a chat panel with 2 buttons, when click both the 2 buttons, the height of container must be reduce or increase.

My way to achieve it is using "textFlow.flowComposer.getControllerAt(0).setCompositionSize(container.newWidth, container.newHeight)",

but it is more likely the scaleX&scaleY of the container is changed.

I am very sad with this, so I post it here wish there is anyone who can help me in solving this.

And I am fresh in using TLF. Is using "use namespace tlf_internal" ato read the contentHeight right?

Any answer will be appiciated.

Sorry for my poor English.

Best Regards to You all.

This topic has been closed for replies.

3 replies

Inspiring
September 29, 2010

Check this out:

http://www.oscar-mejia.com/blog/post/tlf-resiable-textflow-container

Participant
September 30, 2010

Dear Oscar:

Thanks a lot for your reply, it is so useful for me.

Thank you very much.

Best Regards

Ado

Adobe Employee
September 11, 2010

Setting the scaleX/scaleY on the ContainerController's container (the Sprite) will do a visual scale of the text. Calling setCompositionSize on the ContainerController keeps the text the same size, but changes the amount of space available to it for laying out text. So which one you want depends on which kind of change you want. In either case, calling contentHeight won't change anything. However, if you want to set the container to be big enough vertically to fit all the text, you can get the contentBounds (call getContentBounds) and then resize it to the width and height of the content bounds. If you have more text than fits, you may need to call textFlow.flowComposer.composeToPosition() before calling getContentBounds to insure that all the text is composed first.

I hope this helps point you in the right direction.

- robin

Adobe Employee
September 10, 2010

I think you should use ContainerController.getContentBounds() to get the bounds and set the height from the returned Rectangle instead of using

contentHeight.  It's going to be the same value.

The container is a Flash Sprite object not a TLF object.  Setting width/height properties of a Sprite does indeed set the scaleX/scaleY.  If you don't want to scale the container its better to treat Sprite width/height properties as read-only.  I think the solution is to not set width/height of the Sprite but rather track desired width/height in separate variables perhaps by subclassing Sprite and set those values into TLF.

Hope that helps,

Richard