4 Replies Latest reply on Oct 30, 2009 11:31 AM by ngarg

    Scroller viewport detection

    ngarg Level 1

      Hi,

       

      I facing a small issue. I have a list of DisplayObject inside a scroller. I want detect which all objects are currently within the viewport. How can I do it? I am using the spark Scroller component.

       

      thanks

        • 1. Re: Scroller viewport detection
          David_F57 Level 5

          Hi,

           

          displayobject iformation for your scroller can be retreived through the layout, layout as the following three that may be of help to you

          firstIndexInView

          lastIndexInView

           

          for verticallayout

          rowCount

           

          for horizontallayout

          columnCount

           

           

          this code below is a scroller for a horizontal list

          <s:Scroller left="30" top="0" right="30" bottom="0" id="scroller" minViewportInset="1" focusEnabled="false">

          <s:DataGroup id="dataGroup" left="30" right="30" itemRenderer="comp.ImageRender">

                <s:layout>

                          <s:HorizontalLayout id="hl" gap="0" paddingBottom="0" paddingLeft="0" paddingRight="0" paddingTop="0" />

                </s:layout>

          </s:DataGroup>

          </s:Scroller>

           

          you can retreive the info

          var viewCount:int=hl.columnCount;

          var IndexOne:int=hl.firstIndexInView;

          var IndexLast:int=hl.lastIndexInView;

           

           

          hope this helps.

           

          David.

          • 2. Re: Scroller viewport detection
            Shongrunden Adobe Employee

            If you are using a VerticalLayout or HorizontalLayout you could also use the  fractionOfElementInView() method of the layout.

            • 3. Re: Scroller viewport detection
              David_F57 Level 5

              @ Shongrunden,

              didn't know about that one

               

              thanks..

              David

              • 4. Re: Scroller viewport detection
                ngarg Level 1

                fractionOfElementInView turned out to be really useful.

                 

                thanks