0) { lblFooter.text = "© Bas van Dijk - 2008"; lblTitle.text = "Flex 3 gallery test"; loadImage(0); lstThumbnails.selectedIndex = 0; } checkScroll(); } // Fires when the scroll next button of the thumbnaillist is clicked private function cmdScrollNext_click():void { var newPos:int = lstThumbnails.horizontalScrollPosition + 1; if (newPos <= lstThumbnails.maxHorizontalScrollPosition) { lstThumbnails.horizontalScrollPosition = newPos; } checkScroll(); } // Fires when the scroll previous button of the thumbnaillist is clicked private function cmdScrollPrev_click():void { var newPos:int = lstThumbnails.horizontalScrollPosition - 1; if (newPos >= 0) { lstThumbnails.horizontalScrollPosition = newPos; } checkScroll(); } // Check the scrollposition of the list and hides the previous and next buttons if neccesary private function checkScroll():void { // Check if the scroll position is at the start position of the list // if so hide the scroll previous button if (lstThumbnails.horizontalScrollPosition == 0) { cmdScrollPrev.visible = false; } else { cmdScrollPrev.visible = true; } // Check if the scroll position is at the max position of the list // if so hide the scroll next button if (lstThumbnails.horizontalScrollPosition == lstThumbnails.maxHorizontalScrollPosition) { cmdScrollNext.visible = false; } else { cmdScrollNext.visible = true; } } // Fires when the user clicks on a thumbnail private function lstThumbnails_itemClick(evt:ListEvent):void { imgMain.source = evt.itemRenderer.data.src; lblImageTitle.text = evt.itemRenderer.data.lbl; } // Loads a specific image private function loadImage(imageNumber:int):void { imgMain.source = arrImages[imageNumber].src; lblImageTitle.text = arrImages[imageNumber].lbl; } // Fired then the user clicks on an image for the next picture private function imgMain_click():void { if (lstThumbnails.selectedIndex < arrImages.length) { lstThumbnails.selectedIndex += 1; lstThumbnails.scrollToIndex(lstThumbnails.selectedIndex); loadImage(lstThumbnails.selectedIndex); checkScroll(); } } ]]>