如何告诉滚动窗格使用actionscript向上或向下滚动?

如何告诉滚动窗格使用actionscript向上或向下滚动?,actionscript,scrollpane,Actionscript,Scrollpane,我想触发一个事件,使滚动窗格开始向上或向下滚动 理想情况下,滚动窗格将继续向上或向下滚动,除非被其他事件取消。如下所示: this.createClassObject(mx.containers.ScrollPane, "my_sp", 10); my_sp.setSize(360, 280); this.createEmptyMovieClip("button_up",this.getNextHighestDepth()); this.createEmptyMovieClip("button_

我想触发一个事件,使滚动窗格开始向上或向下滚动


理想情况下,滚动窗格将继续向上或向下滚动,除非被其他事件取消。

如下所示:

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

抱歉,忘了在其中添加一个内容,即您需要在这些按钮中实际放置一些内容,以便它们不仅仅是空的电影剪辑,实际上可以像按钮一样工作:)属性是:maxVPosition(以防有人在寻找姓名)