0 Replies Latest reply on Dec 15, 2010 12:16 PM by learningflex

    auto scroll contents of datagrid

    learningflex

      I have written this functionto autoscroll the contents of the datagrid. i call the scrollDG method for the datagrid i want to scroll automatically. It scrolls automatically only once and goes to the next row, does not go till the end of the datagrid. Any suggestions please??

       

      private var scrollTimer:Timer = new Timer(0,0);

       

       

       

      private function scrollDG(dg:DataGrid):void

      {

       

      /*If scrollable start a timer and loop through til you hit the max vertical scroll position

      then reverse*/

      currDg = dg;

       

      if(currDg.maxVerticalScrollPosition > 0){

       

       

      if(scrollTimer.running){

      scrollTimer.reset();}

      scrollTimer =

      new Timer(3000,currDg.maxVerticalScrollPosition);

      scrollTimer.addEventListener(TimerEvent.TIMER,onScrollTimer);

      scrollTimer.start();

       

      }

       

      }

       

      private function onScrollTimer(event:TimerEvent):void{

       

      if(currDg.verticalScrollPosition < currDg.maxVerticalScrollPosition)

      {

      currDg.validateNow();

      currDg.verticalScrollPosition = currDg.verticalScrollPosition + 1;

      scrollDG(currDg);

      }

       

      else{

      currDg.verticalScrollPosition = 0;

      }

       

      if(currDg.verticalScrollPosition == currDg.maxVerticalScrollPosition )

      {

      currDg.verticalScrollPosition == currDg.maxVerticalScrollPosition;

      scrollDG(currDg);

      }

      }