Skip to main content
Known Participant
July 30, 2012
Question

Detect when a spark Scroller is changing scroll position

  • July 30, 2012
  • 2 replies
  • 2217 views

<s:Scroller right="0" left="0"




bottom="0"




top="0"




>


<s:horizontalScrollBar>



<s:HScrollBar id="hbar" change="bottomscoller_hScrollBar_change(event)" />


</s:horizontalScrollBar>


<s:HGroup gap="0"




  >



....stuff here


</s:HGroup>

</s:Scroller>

then i have that function but it never gets called.

anyone know how to find out when this scroller has been scrolled?

This topic has been closed for replies.

2 replies

Known Participant
July 31, 2012

I used the flash.events.Event.RENDER event to determine if the scroller has been scrolled/repositioned

a pretty bad listener to be doing "if" statements inside. anyone know a better idea?

what does this mean? "This property can be used as the source for data binding. When this property is modified, it dispatches the propertyChange event."

Kobydo2
Known Participant
August 1, 2013

<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 {
                // spark Scroller: listen on the viewport property
                myScroller.viewport.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, handle);
            }

            /**
             * Handle scroll position changes
             */
            private function handle(e:PropertyChangeEvent):void {
                if (e.source == e.target && e.property == "verticalScrollPosition")
                    trace(e.property, "changed to", e.newValue);
                if (e.source == e.target && e.property == "horizontalScrollPosition")
                    trace(e.property, "changed to", e.newValue);
            }
        ]]>
   
</fx:Script>

   
<s:Scroller id="myScroller" width="100" height="100">
       
<s:Group>
           
<s:Button label="large content" width="300" height="300"/>
       
</s:Group>
   
</s:Scroller>

</s:Application>

Known Participant
July 31, 2012

Default Detect when a spark Scroller is changing scroll position


ActionScript Code:

<s:Scroller right="0" left="0" top="0" bottom="0"
<s:horizontalScrollBar>
<s:HScrollBar id="hbar" change="bottomscoller_hScrollBar_change(event)" />
</s:horizontalScrollBar>
<s:HGroup gap="0">  ....stuff here  </s:HGroup> 
</s:Scroller>


then i have that function "bottomscoller_hScrollBar_change" but it never gets called.


anyone know how to find out when this scroller has been scrolled?