4 Replies Latest reply on Jul 9, 2008 6:10 PM by JasonBuberel

    Q: How to automatically size a popup dialog

    JasonBuberel Level 1
      In my Flex3 application, I use a generic 'Access Denied' component to display messages to users. The top-level element that forms the basis of this component is a mx:TitleWindow. Within the title window is a text field and a cancel button at the bottom. The actual contents of the text field can vary, depending on the nature of the error message to be displayed. The PopUpManager is used to display/hide the dialog.

      What I would like to do is set the width of the dialog to 300px, and to configure the vertical height of the dialog to adjust dynamically in order to show the entire text field content.

      I have been looking at the TextField class, which has a numLines property as well as the getLineMetrics method to calculate the height of the text and then to determine if the height of the dialog needs to be increased in order to ensure all of the text is displayed. But this process seems to be much too labor intensive for something so simple.

      Is there a better solution?