我想触发一个导致ScrollPane开始向上或向下滚动的事件。
理想情况下,ScrollPane会滚动继续向上或向下滚动,除非被其他事件取消。
答案 0 :(得分:2)
会是这样的:
this.createClassObject(mx.containers.ScrollPane, "my_sp", 10);
my_sp.setSize(360, 280);
this.createEmptyMovieClip("button_up",this.getNextHighestDepth());
this.createEmptyMovieClip("button_down",this.getNextHighestDepth());
this.createEmptyMovieClip("button_left",this.getNextHighestDepth());
this.createEmptyMovieClip("button_right",this.getNextHighestDepth());
button_up.onPress=function(){
my_sp.onEnterFrame=function(){
this.vPosition -= 5;
}
}
button_down.onPress=function(){
my_sp.onEnterFrame=function(){
this.vPosition += 5;
}
}
button_left.onPress=function(){
my_sp.onEnterFrame=function(){
this.hPosition -= 5;
}
}
button_right.onPress=function(){
my_sp.onEnterFrame=function(){
this.hPosition += 5;
}
}
//replace this with whatever event you want to use to make the scrolling stop
button_right.onRollOut = button_left.onRollOut = button_up.onRollOut = button_down.onRollOut = function(){
my_sp.onEnterFrame=undefined;
}
你必须检查_hmax和_vmax,以确保不滚动滚动条自然停在的内容的末尾。我不记得这些变量的名称是什么,但如果你在调试模式下运行你的程序并围绕滚动窗格实例,你应该找到它。如果将内置滚动条移动到底部并查看变量变化,然后找到匹配的变量并且是静态的,则可能会更容易。