2 Replies Latest reply on Oct 18, 2010 3:48 PM by fuyuko1979

    Hbox in view stack does not update width

    fuyuko1979

      Hi there,   I'm working on flash builder and I have four hboxes nested inside a view stack. I dynamically populate each hbox with images grabbed from the database. For some reason only the visible hbox correctly updates its' width while the other 3 hbox takes on the width of this one so I end up with all four hbox having the same width. This is a problem when I have lots of images in one than the other and some of them gets cut off.

      The hboxes do not have scroll bars as the viewstack has a mouse easing scroller function attached to it - the hbox scrolls according to the position of the mouse.

       

      Am I doing something wrong here?

       

      <mx:Canvas height="110"
                         width="663"
                         visible.loginState = "false"
                         x="10"
                         y="577" horizontalScrollPolicy="off" verticalScrollPolicy="off" id="viewStackContainer">
                  <mx:ViewStack id="myViewStack" creationPolicy="all"
                                borderStyle="none">
                      <!-- Books Library -->
                      <mx:HBox horizontalAlign="left" verticalScrollPolicy="off" horizontalScrollPolicy="off" verticalAlign="middle" horizontalGap="0" id="books" />
                     
                      <!-- EBooks Library -->
                      <mx:HBox horizontalAlign="left" verticalScrollPolicy="off" horizontalScrollPolicy="off" verticalAlign="middle" horizontalGap="0" id="ebooks" />
                     
                      <!-- Recordings Library -->
                      <mx:HBox horizontalAlign="left" verticalScrollPolicy="off" horizontalScrollPolicy="off" verticalAlign="middle" horizontalGap="0" id="recordings" />
                     
                      <!-- Readings Library -->
                      <mx:HBox horizontalAlign="left" verticalScrollPolicy="off" horizontalScrollPolicy="off" verticalAlign="middle" horizontalGap="0" id="readings" />
                       
                  </mx:ViewStack>
              </mx:Canvas>

        • 1. Re: Hbox in view stack does not update width
          Flex harUI Adobe Employee

          Image loading external content won't have a useful size at the time things

          get measured.  What do you want to have happen as the images come in?  Do

          you want the viewstack to change in size?  I think resizeToContent=true will

          do that.  If you can know ahead of time the size you want, setting that on

          the viewstack would be better (and you'd save on the overhead of

          creationPolicy="all")

          • 2. Re: Hbox in view stack does not update width
            fuyuko1979 Level 1

            Hi thanks for your reply. As the hbox gets populated i need it to resize itself. Once each hbox has been populated with the images I attach a function to the viewstack which allows me to scroll the hbox with mouse position - so it scrolls horizontally depending on where the mouse is in relation to the viewstack. So as you can see I need by this point for each hbox to have resized in order to correctly calculate my scrolling function.  The bizarre thing is the selected Index hbox displays all the images but the rest of the hboxes takes on the same width as this one and this is a problem because some of my other hbox contains more images.  As a test I set the selected Index of the viewStack to be the third Hbox, then I restarted the application and now all the hbox takes on the wdith of this one.   I am creating a library of thumbnails which is dynamically driven. It's not possible for me to predetermine the width of each. Do you have any suggestions for this?