手动滚动列表

时间:2013-05-22 09:06:19

标签: flash flex list flash-builder

我需要使用箭头键手动处理滚动列表,而我成功处理通过项目更改选择,如果列表大于其显示并需要使用滚动条,那么滚动条不会wscroll使用所选项目。

这就是我现在所拥有的:

        function completionListUpDown(direction:Boolean):void{
            if(direction){
                if(popUp.completionList.dataProvider.length == (popUp.completionList.selectedIndex + 1)){
                    popUp.completionList.selectedIndex = 0;
                }
                else{
                    popUp.completionList.selectedIndex += 1;
                }

            }
            else{
                if(0 == popUp.completionList.selectedIndex){
                    popUp.completionList.selectedIndex = popUp.completionList.dataProvider.length - 1;
                }
                else{
                    popUp.completionList.selectedIndex -= 1;
                }
            }
        }

这会滚动像魅力一样的项目,但是如果有一个垂直滚动条,则该滚动条不会滚动。如何使滚动滚动?

1 个答案:

答案 0 :(得分:0)

LOL,没关系,我刚刚找到解决方案,只需使用ensureIndexIsVisible(selectedIndex)

        function completionListUpDown(direction:Boolean):void{
            if(direction){
                if(popUp.completionList.dataProvider.length == (popUp.completionList.selectedIndex + 1)){
                    popUp.completionList.selectedIndex = 0;
                }
                else{
                    popUp.completionList.selectedIndex += 1;
                }

            }
            else{
                if(0 == popUp.completionList.selectedIndex){
                    popUp.completionList.selectedIndex = popUp.completionList.dataProvider.length - 1;
                }
                else{
                    popUp.completionList.selectedIndex -= 1;
                }
            }
            popUp.completionList.ensureIndexIsVisible(popUp.completionList.selectedIndex);
        }