2 Replies Latest reply on Jun 11, 2010 5:38 AM by UbuntuPenguin

    List overflow detection

    UbuntuPenguin Level 4

      Hey Everyone ,

        I have a list , which has a variable height itemrenderer.  What I would like to know , is there anyway I can detect when the amount of content in the list causes its scrollers to activate ?  The way I am currently investigating involves accessing the itemrenderers , and comparing the sum of their heights to that of the list.  I have yet to hash that out yet.

       

      Ubu

       

      Points will be awarded for successful answers.

        • 1. Re: List overflow detection
          Shongrunden Adobe Employee

          You could check if contentHeight is larger than height on the List's DataGroup skin part.  Or you could check the visible property of the verticalScrollBar skin part of the Scroller:

          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                         xmlns:s="library://ns.adobe.com/flex/spark">
              <fx:Script>
                  <![CDATA[
                      private function checkScrollbars():void {
                          if (list1.dataGroup.contentHeight > list1.dataGroup.height){
                              trace("scrollbars on");
                          } else {
                              trace("scrollbars off");
                          }
                      }
                     
                      private function checkScrollbars2():void {
                          if (list1.scroller.verticalScrollBar.visible == true){
                              trace("scrollbars on");
                          } else {
                              trace("scrollbars off");
                          }
                      }
                  ]]>
              </fx:Script>
             
              <s:VGroup>
                  <s:Button label="test for scrollbars" click="checkScrollbars()" />
                  <s:Button label="test for scrollbars 2" click="checkScrollbars2()" />
                  <s:HSlider id="slider" minimum="100" maximum="300" />
                  <s:List id="list1" height="{slider.value}">
                      <s:dataProvider>
                          <s:ArrayList>
                              <fx:String>one</fx:String>
                              <fx:String>one</fx:String>
                              <fx:String>one</fx:String>
                              <fx:String>one</fx:String>
                              <fx:String>one</fx:String>
                              <fx:String>one</fx:String>
                              <fx:String>one</fx:String>
                              <fx:String>one</fx:String>
                              <fx:String>one</fx:String>
                              <fx:String>one</fx:String>
                              <fx:String>one</fx:String>
                          </s:ArrayList>
                      </s:dataProvider>
                  </s:List>
              </s:VGroup>
             
          </s:Application>
          • 2. Re: List overflow detection
            UbuntuPenguin Level 4

            That's exactly what I did ! I  used the scroller that was on the skin component and made sure it wasn't visible.

             

            Thanks ,

              Ubu