Scroll to selected item in Flex 4 Spark List component?

Thanks, but it seems working in latest Flex 4 SDK builds only (Flex Builder 4 Beta 2). I realized I work with one of old builds that has no this method yet. – Rodion Bykov Nov 13 '09 at 22:17 this also only scrolls so that the top of the item is visible, if the item is tall this does not scroll to the bottom – JTtheGeek Dec 1 '10 at 23:48.

In flex-3 there is a scrollToIndex method and hence you can call list. ScrollToIndex(list. SelectedIndex); I believe this should work in flex-4 too.

Unfortunately, no. There's no such method in Spark List, but it's there for Halo List component. Flex 4 is evolving and still in Beta, hope this issue will be resolved.

– Rodion Bykov Oct 29 '09 at 11:23.

You'll probably want to access the List's scroller directly and do something like: list.scroller.scrollRect. Y = list.itemRenderer. Height * index.

I recently accomplished this in one of my projects by having a defined size for my items in the group.. Following this my button controls for manipulation worked by incrementing a private "targetindex" variable, then I called a checkAnimation function, which used the Animate class, in combo with a SimpleMotionPath and a comparison between tutpane. FirstIndexInView and target index. This modified the "horizontalScrollPosition" of the group.

This allowed separate controls to essentially act as a scroll bar, but I had the requirement of sliding the control to view the selected item.. I believe this technique could work for automated selection of items as well.

I saw this basic idea here... arthurnn.com/blog/2011/01/12/coverflow-l... public function scrollGroup( n : int ) : void { var scrollPoint : Point = theList.layout. GetScrollPositionDeltaToElement( n ); var duration : Number = ( Math. Max( scrollPoint.

X, theList.layout.target. HorizontalScrollPosition ) - Math. Min( scrollPoint.

X, theList.layout.target. HorizontalScrollPosition )) * .01; Tweener. AddTween(theList.

Layout,{ horizontalScrollPosition: scrollPoint. X , time:duration}); } protected function theList_caretChangeHandler(event:IndexChangeEvent):void { scrollGroup( event. NewIndex ); event.target.

InvalidateDisplayList(); }.

This function will scroll to the top of the list in Flex 4+. It takes in account the height of the item, so it will work for lists with different items with different height. 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; } } }.

You can multiply the height of an element by its index and pass this value to: yourListID.scroller.viewport. VerticalScrollPosition.

Try the s:List method ensureIndexIsVisible(index:int):void .

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions