2 Replies Latest reply on Jun 7, 2010 12:59 AM by monkeymagiic

    Listen to when spark scroller is scrolling

    monkeymagiic

      Hi Flex

       

      I suppose the title/header describes what I'm looking for,

       

      Which event would I hook into to trigger event when a user is currently scrolling a spark component (In this case a spark list)

       

      Many Thanks

       

      MonkeyMagiic

        • 1. Re: Listen to when spark scroller is scrolling
          Shongrunden Adobe Employee

          One way is to listen for the "propertyChange" event on the layout of a spark container and then check if the change was on the verticalScrollPosition or horizontalScrollPosition properties.

           

          For example:

          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                         xmlns:s="library://ns.adobe.com/flex/spark"
                         creationComplete="init()">
             
              <fx:Script>
                  <![CDATA[
                      import mx.events.PropertyChangeEvent;
                     
                      private function init():void {
                          list1.layout.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, handle);
                      }
                     
                      private function handle(e:PropertyChangeEvent):void {
                          if (e.property == "verticalScrollPosition" ||
                              e.property == "horizontalScrollPosition"){
                         
                              trace("scroll position changed");
                          }
                      }
                  ]]>
              </fx:Script>
             
              <s:List height="50" id="list1">
                  <s:dataProvider>
                      <s:ArrayList>
                          <fx:String>one</fx:String>
                          <fx:String>two</fx:String>
                          <fx:String>three</fx:String>
                          <fx:String>four</fx:String>
                          <fx:String>five</fx:String>
                          <fx:String>six</fx:String>
                          <fx:String>seven</fx:String>
                      </s:ArrayList>
                  </s:dataProvider>
              </s:List>
          </s:Application>