如何使用动作脚本告诉 ScrollPane 向上或向下滚动?

发布于 2024-07-07 09:41:58 字数 90 浏览 8 评论 0原文

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

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

I want to trigger an event that causes the ScrollPane to start scrolling up or down.

Ideally the ScrollPane would scroll continue to scroll all the way up or down unless canceled by another event.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜无邪 2024-07-14 09:41:58

会是这样的:

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

Would be something like this:

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;
}

You'll have to check the _hmax and _vmax to make sure you don't scroll past the end of the content, where the scrollbar would naturally stop at. I don't remember off the top of my head what the names of these variables are, but if you run your program in debug mode and poke around the scrollpane instance, you should find it. It'll probably be easier if you move the built-in scrollbar to the bottom and see what variable changes, then find the one that matches and is static.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文