6 Replies Latest reply on Mar 28, 2009 6:11 PM by ice9_us

    Dynamically changing  size of textbox in list

    dbStroud
      All- I have been having a bit of a problem solving this. Perhaps you can help?

      I have created a window that opens and displays a dictionary. At the top of the window is a line of link buttons (A-Z). Below, is a list component (I have tried both the list and tile list components). When the end-user selects a link button, data from a corresponding xml file loads into an item renderer containing two text fields (one for the word, and one for the definition) which gets displayed in the list component. Since each letter will have a different number of word entries, and each word entry will have various lengths of text, I need the the text box containing the definition to dynamically resize, thereby resizing the item renderer. Once this happens, I need the list to distribute the item renderer evenly.

      I have successfully loaded the text, wrote script to handle the resize and have the list displaying the item renderers. However, on the letters that have more than one word entry, the list box displays the item renderers oddly. Some will have a gap between the entries large enough to get another item renderer in. However, when I click around on different letters, the multiple entried ones will sometimes load correctly. When I go back to the ones that did not, they will load correctly. Sometimes requiring several tries. Any ideas as to what might be causing this? Any simpler ways to accomplish my task? Thanks. -David
        • 1. Re: Dynamically changing  size of textbox in list
          jhapak
          If you are not taking any input from the user, try using Text instead of textinput. Also, use it in the form.

          Regards
          Saqib
          • 2. Re: Dynamically changing  size of textbox in list
            Level 7

            "dbStroud" <webforumsuser@macromedia.com> wrote in message
            news:gq89nb$4fh$1@forums.macromedia.com...
            > All- I have been having a bit of a problem solving this. Perhaps you can
            > help?
            >
            > I have created a window that opens and displays a dictionary. At the top
            > of
            > the window is a line of link buttons (A-Z). Below, is a list component (I
            > have
            > tried both the list and tile list components). When the end-user selects
            > a
            > link button, data from a corresponding xml file loads into an item
            > renderer
            > containing two text fields (one for the word, and one for the definition)
            > which
            > gets displayed in the list component. Since each letter will have a
            > different
            > number of word entries, and each word entry will have various lengths of
            > text,
            > I need the the text box containing the definition to dynamically resize,
            > thereby resizing the item renderer. Once this happens, I need the list to
            > distribute the item renderer evenly.
            >
            > I have successfully loaded the text, wrote script to handle the resize and
            > have the list displaying the item renderers. However, on the letters that
            > have
            > more than one word entry, the list box displays the item renderers oddly.
            > Some
            > will have a gap between the entries large enough to get another item
            > renderer
            > in. However, when I click around on different letters, the multiple
            > entried
            > ones will sometimes load correctly. When I go back to the ones that did
            > not,
            > they will load correctly. Sometimes requiring several tries. Any ideas as
            > to
            > what might be causing this? Any simpler ways to accomplish my task?
            > Thanks.

            1) You need to make sure you override measure() to provide an accurate
            height for your renderer
            2) you need to set the List's variableRowHeight property to true.

            HTH;

            Amy


            • 3. Re: Dynamically changing  size of textbox in list
              Gregory Lafrance Level 6
              Maybe newlines in your text is messing you up.

              You might try using a Label for the word, and then just feed to multiple (or single) definitions into a collection to feed the List. In the function feeding the collection, perhaps strip out whatever is causing the problem Iline feeds, etc.)

              I don't know if you have hard requirements for how this is to be displayed, but you could even just use a Repeater for the definitions, with repeated Text controls, thus avoiding the list altogether.

              Just a few more ideas.
              • 4. Re: Dynamically changing  size of textbox in list
                dbStroud Level 1
                Amy, thanks very much for your reply. I wonder if you could guide me through the process of overriding measure. Is this something I can do right inside of my itemRenderer? Or, should I be put into a package. I'm a little sketchy on creating custom classes, I've only done it once or twice and awhile ago. In the reading that I have done, when I write the override function, I need to give it the correct measurements. Would something like this work?

                override protected function measure():void{
                wordDefTxtAr.explicitHeight = wordDefTxtAr.textHeight+10;
                this.measuredHeight = wordEntryTxt.explicitHeight + wordDefTxtAr.explicitHeight+10;
                }

                Thanks- david


                • 5. Re: Dynamically changing  size of textbox in list
                  Level 7

                  "dbStroud" <webforumsuser@macromedia.com> wrote in message
                  news:gqem0q$bab$1@forums.macromedia.com...
                  > Amy, thanks very much for your reply. I wonder if you could guide me
                  > through
                  > the process of overriding measure. Is this something I can do right
                  > inside of
                  > my itemRenderer? Or, should I be put into a package. I'm a little
                  > sketchy on
                  > creating custom classes, I've only done it once or twice and awhile ago.
                  > In
                  > the reading that I have done, when I write the override function, I need
                  > to
                  > give it the correct measurements. Would something like this work?
                  >
                  > override protected function measure():void{
                  > wordDefTxtAr.explicitHeight = wordDefTxtAr.textHeight+10;
                  > this.measuredHeight = wordEntryTxt.explicitHeight +
                  > wordDefTxtAr.explicitHeight+10;
                  > }

                  I think that it gets a bit dicey to get the size of text fields. If I were
                  you, I'd google measuring text areas in Flex components or something like
                  that.


                  • 6. Re: Dynamically changing  size of textbox in list
                    ice9_us Level 1
                    have you tried nesting a hbox in a vbox while allowing for text scroll or something along those lines?