Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Reply
 
Thread Tools Rate Thread Display Modes
Old 03-20-2012, 09:25 AM   #1
Raji.S
Member
 
Join Date: Aug 2009
Location: Chennai
Posts: 63
Default AutoScroll for List

Hi friends,
I am developing a mobile project in flex4.6. I am using List Component in my project. i need to scroll the list at runtime using script. For Example, if i give index number=5, the list automatically has to scroll to the 5th index position.I used the below code, but it's working well sometimes only.

ActionScript Code:
scrollToIndex(theList,5); private function scrollToIndex(list:List,index:int):void {                  if (!list.layout)                              return;                      var dataGroup:DataGroup = list.dataGroup;                      var spDelta:Point = dataGroup.layout.getScrollPositionDeltaToElement(index);                                 if (spDelta)                      {                              //dataGroup.horizontalScrollPosition += spDelta.x;                              //move it to the top if the list has enough items                        if(spDelta.y > 0)                              {                            var maxVSP:Number = dataGroup.contentHeight - dataGroup.height;                                      var itemBounds:Rectangle = list.layout.getElementBounds(index);                                      var newHeight:Number = dataGroup.verticalScrollPosition + spDelta.y + dataGroup.height - itemBounds.height;                                                  dataGroup.verticalScrollPosition = Math.min(maxVSP, newHeight);                                                }                              else                     {                            dataGroup.verticalScrollPosition += spDelta.y;                                         }                 }              }
Please help me.
Raji.S is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:38 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.