actionscript - Scrolling 2 lists with 1 scroller Flex 4 -
been trying scroll 2 lists native scrollers disabled 1 scroller added right of them.
i tried setting viewport of each list scroller , while works instantiates scroller each of lists rather use 1.
essentially i'm trying have them scroll vertically @ same time while dragging 1 scrollbar thumb.
i thought interesting question , did little investigation. here came with.
<?xml version="1.0" encoding="utf-8"?> <s:application xmlns:fx="http://ns.adobe.com/mxml/2009"             xmlns:s="library://ns.adobe.com/flex/spark"             xmlns:mx="library://ns.adobe.com/flex/mx"             initialize="application1_initializehandler(event)"            creationcomplete="application1_creationcompletehandler(event)"> <fx:script>     <![cdata[         import flashx.textlayout.container.scrollpolicy;          import mx.collections.arraycollection;         import mx.events.flexevent;         [bindable] private var dp:arraycollection = new arraycollection();         protected function application1_initializehandler(event:flexevent):void         {             //add dummy content             (var i:int=0; i<20; i++){                 dp.additem("test item " + i);             }             //turn off vertical scrolling 2 lists             list1.scroller.setstyle("verticalscrollpolicy", scrollpolicy.off);             list2.scroller.setstyle("verticalscrollpolicy", scrollpolicy.off);         }           protected function vscroll_changehandler(event:event):void         {             //set maximum of 1 scroll bar equal maximum value of hidden scroll bar             vscroll.maximum = list1.scroller.verticalscrollbar.maximum;             //set scroll position of 2 hidden scroll bars value of visible bar             list1.scroller.verticalscrollbar.value = vscroll.value;             list2.scroller.verticalscrollbar.value = vscroll.value;         }           protected function application1_creationcompletehandler(event:flexevent):void         {             //initialize maximum value value of hidden scroll bar after data has been loaded             vscroll.maximum = list1.scroller.verticalscrollbar.maximum;         }      ]]> </fx:script>  <s:hgroup>     <s:list id="list1" dataprovider="{dp}" height="200"/>      <s:list id="list2" dataprovider="{dp}" height="200"/>     <s:vscrollbar id="vscroll" height="200" change="vscroll_changehandler(event)"/> </s:hgroup>  </s:application>      
Comments
Post a Comment