Been trying that but keep getting a very odd error
my code looks like a bit like this
var tryFilterSource:ArrayCollection = new ArrayCollection(tryHistoryArray);
tryFilterSource.filterFunction = filterByLevel;
historyList.dataProvider = tryFilterSource;
historyList.scrollToIndex( tryFilterSource.length - 1);
if I use scrollToIndex i get an "null reference" error from my custom itemrenderer - but don't get the itemRenderer error if I remove the call to scrollToIndex, if i run traces on the variables that are featured in the lines reported as the source of the error all the variables seem fully polulated with data?!?!?!
Doh me... realised that I need to check if the arraycollection was greater than 0 before trying to scroll to it
this fix the null reference
if(tryFilterSource.length > 1)
historyList.scrollToIndex(tryFilterSource.length - 1);
I've still had a few problems with the scrolling however, if an item renderer is only partial visible it doesn't jump fully into view, I really need for the last item to be fully visibable.
Hmm. That might be a bug, but maybe if you're adding a new item the list hasn't updated its maxHorizontalScrollPosition yet. Try calling historyList.validateNow() before calling scrollToIndex
Flex SDK Developer
Adobe Systems Inc.
Thanks Alex for the suggestion.
Unfortunately the first time the scroll bars appear the item on the far right is still only slightly visible and not in full view even after validateNow() is called
Ended up creating something of a work around for this bug.
I had originally used constraints based postioning to control the size of the list, so - left="20" and right="20" - to ensure the list had a border of 20 pixels on each size. This way the list would have expanded to fit whatever space was available. Doing it this way is when I have the probs with the item as mentioned above.
However I removed the constraints based layout attributes and placed a listener on the parent container of the list to listen for it to resize
I then wrote a function that update the columns visible on the HorizontalList each time the parent container was resized
private function changeHistoryListToFit(event:ResizeEvent):void
var historyColCount:Number = Math.floor((mainContainer.width - 40) / historyList.columnWidth);
if(historyColCount > 2 && (historyColCount != historyList.columnCount))
historyList.columnCount = historyColCount;
when done this way the scrollToIndex() function works without a hitch, still a pain in the arse bug though!