Auto-sizing and positioning in Flex

Posted by Addsy on Stack Overflow See other posts from Stack Overflow or by Addsy
Published on 2010-01-04T15:38:16Z Indexed on 2010/04/05 0:03 UTC
Read the original article Hit count: 547

Filed under:
|
|
|

I am working on a flex app that uses XML templates to dynamically create DisplayObjects. These templates define different layouts that can be used for each page of content in the app (ie , 2 columns, 3 columns etc etc). The administrator can select from one of these and populate each area with their content.

The templates add one of 3 types of DisplayObject - HBox, VBox or a third component - LibraryContentContainer (an mxml component that is defined as part of the app) - which is effectively a canvas element with a TextArea inside.

The problem that I am getting is that I need each of these areas to automatically resize to fit the length of the content but don't seem to be able to find an effective way to do so.

In the LibraryContentContainer, when the value of the TextArea is set, I am calling .validateNow() on the LibraryContentContainer. I then set the height property on both the TextArea and LibraryContentContainer to match the textHeight property of the TextArea.

In the following example, this is the LibraryContentContainer, viewer is the TextArea and the value property of the TextArea is bound to this.__Value. v is the variable containing the content for the textarea

this.__Value = v;
this.validateNow();

this.viewer.height = this.viewer.textHeight;
this.height = this.viewer.height; 

This works to a degree in that the TextArea grows or shrinks depending on the length of content, but it's still not great - sometimes there are still vertical scrollbars even tho the size of the TextArea has grown.

Anyone got any ideas?

Thanks

Adam

© Stack Overflow or respective owner

Related posts about flex

Related posts about flex3