0

我想触发一个导致 ScrollPane 开始向上或向下滚动的事件。

理想情况下,ScrollPane 将滚动继续向上或向下滚动,除非被另一个事件取消。

4

1 回答 1

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 以确保您不会滚动到内容的末尾,滚动条会自然停止。我不记得这些变量的名称是什么,但是如果您在调试模式下运行程序并浏览滚动窗格实例,您应该会找到它。如果您将内置滚动条移到底部并查看哪些变量发生了变化,然后找到匹配且是静态的,这可能会更容易。

于 2009-01-04T09:55:46.243 回答