1 Reply Latest reply on Sep 11, 2007 11:25 PM by jfillman

    Set Scroll Position to dynamic items?


      I have a canvas that contains many elements created from a repeater, this canvas contains
      a scroll bar since there are more elements than the size of the
      canvas.. I also have some buttons at the top of the page. I want
      these buttons to cause the canvas to focus or scroll to these
      componts when pressed.. This can easily be done in html.. how about
      in flex?

      I tried storing the y position of each element and then use the
      canvas.verticalScrollPosition = element[0].y.. but because it seems
      that becuase the element is in a repeater it doesn't store the y

      There has got to be an easy way to do this!
      Any help or direction you can give me would be appreciated!


        • 1. Re: Set Scroll Position to dynamic items?
          There might be a cleaner way, but if you have a fixed number of items, set a fixed height, and then do some simple math to calculate the y position.

          For example, if each repeater item is 20 pixels high and starts at 10 pixels from the top:

          Item 1.verticalScrollPosition = (currentItem * 20) + 10;
          //equals 10

          Item 5.verticalScrollPosition = (currentItem * 20) + 10;
          //equals 110