动画剪辑内的 AS3 按钮用作滚动窗格的一部分 - 不起作用

发布于 2025-01-05 02:26:59 字数 272 浏览 1 评论 0原文

我是一个动作脚本初学者,所以我希望你在回复时考虑到这一点。我遇到的问题是,客户要求我在滚动的文本框中放置一个号召性用语按钮。我的想法是创建一个包含文本和按钮的影片剪辑,然后将该影片剪辑放置在滚动窗格中。我整天都在胡闹,但进展甚微。我什至不确定实现这一目标的最佳方法。

如果你们中的一位学过动作脚本的人可以为我指明正确的方向,也许我可以找到自己的解决方案。

客户希望我为滚动条使用自定义图标,并且由于更改滚动条组件看起来像这样的 PIA,因此我试图避免使用组件。

任何帮助将不胜感激!

I'm a beginner actionscripter, so I hope you will take that into account when replying. The problem I am having is that a client has asked me to place a call to action button inside a textbox that scrolls. My idea was to create a movieclip containing the text and the button, then place that movieclip inside a scroll pane. I've been monkeying around with it all day and have made minimal headway. I'm not even sure of the best way to accomplish this.

If one of you learned actionscripters out there could point me in the right direction, perhaps I can find my own solution.

The client wants me to use custom icons for the scrollbars, and as altering a scrollbar component seems like such a PIA, I'm trying to avoid using components.

Any help would be appreciated!

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

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

发布评论

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

评论(2

煮酒 2025-01-12 02:26:59

为什么不让按钮在用户向下滚动到文本框底部时显示呢?将按钮实际上“放入”滚动框似乎不太干净,特别是如果用户再次向上滚动,则按钮将被隐藏。

假设您的舞台上有一个名为“text_txt”的 TextField、一个名为“someButton_mc”的 SimpleButton 或 MovieClip 以及一个名为“scrollBar_mc”的 UIScrollBar(来自组件);
在滚动条的属性中,将“scrollTargetName”设置为“text_txt”,以将滚动条链接到文本字段。然后编写如下代码:

import fl.controls.UIScrollBar;
import fl.events.ScrollEvent;

//Hide the "Call to action" button
someButton_mc.visible = false; 

var sb:UIScrollBar = UIScrollBar(scrollBar_mc);

//Monitor when user scrolls
sb.addEventListener(ScrollEvent.SCROLL, didScroll);

function didScroll(evt:ScrollEvent):void {
    //Check if user scrolled to bottom
    if(sb.scrollPosition == sb.maxScrollPosition){
        //Show button if at bottom
        someButton_mc.visible = true; 
        //Cleanup event listener since no longer needed
        sb.removeEventListener(ScrollEvent.SCROLL, didScroll);
    }
}

给滚动条蒙皮并不像您想象的那么糟糕,至少一旦您弄清楚了。有很多关于皮肤或制作自定义滚动条的教程。让我知道这是否有帮助或者我是否误解了。

另一件事:确保“text_txt”是多行的,并且具有大量用于测试目的的文本。

Why not just have the button show up when the user scrolls down to the bottom of the textbox? Putting the button actually "in" the scroll box doesn't seem very clean, especially if the user then scrolls back up again then the button would be hidden.

Assuming on your stage have a TextField named "text_txt", a SimpleButton or MovieClip named "someButton_mc" and a UIScrollBar (from the components) named "scrollBar_mc";
In the scrollbar's properties set "scrollTargetName" to "text_txt" to link the scroll bar to the text field. Then code something like this:

import fl.controls.UIScrollBar;
import fl.events.ScrollEvent;

//Hide the "Call to action" button
someButton_mc.visible = false; 

var sb:UIScrollBar = UIScrollBar(scrollBar_mc);

//Monitor when user scrolls
sb.addEventListener(ScrollEvent.SCROLL, didScroll);

function didScroll(evt:ScrollEvent):void {
    //Check if user scrolled to bottom
    if(sb.scrollPosition == sb.maxScrollPosition){
        //Show button if at bottom
        someButton_mc.visible = true; 
        //Cleanup event listener since no longer needed
        sb.removeEventListener(ScrollEvent.SCROLL, didScroll);
    }
}

Skinning the scroll bar isn't as bad a task as you'd think, at least once you figure it out. There are plenty of tutorials out there for skinning or making a custom scroll bar. Let me know if that helps or if I misunderstood.

One more thing: make sure "text_txt" is multiline and has a good amount of text for testing purposes.

栀梦 2025-01-12 02:26:59

您可以通过actionscript 将文本和按钮添加到scrollPane。可以在此处找到显示基础知识的好教程:

You can add your text and button to a scrollPane via actionscript. A Good tutorial showing the basics can be found here: http://www.parorrey.com/blog/flash-development/as3-add-dynamic-movieclips-to-scrollpane-component-using-flash/

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