AS3 菜单未检测到点击

发布于 2024-10-19 18:39:17 字数 870 浏览 2 评论 0原文

我有一些按钮可以在时间轴上导航。我试图制作一个 switch 语句来节省我编写代码的时间。这是我想出的办法,但它不起作用。每个按钮都具有翻转功能,效果很好。痕迹在那里用于调试。

for (var a=0; a<mainButtons.length; a++){
mainButtons[a].buttonMode = true;
mainButtons[a].addEventListener(rolled, hideDbases);
mainButtons[a].addEventListener(clicked, switchView);
}

function switchView(e:Event):void {
    switch (e.target.name) {
        case "count_btn":
            gotoAndPlay(4);
            trace("count");
        break;
        case "order_btn":
            gotoAndPlay(5);
            trace("order");
        break;
        case "admin_btn":
            gotoAndPlay(6);
            trace("admin");
        break;
        case "serve_btn":
            gotoAndPlay(7);
            trace("service");
        break;
        case "video_btn":
            gotoAndPlay(8);
            trace("video");
        break;
    }
}

I've got some buttons that just navigate around the timeline. I was trying to make a switch statement that would save me some time writing code. This is what I've come up with, but it doesn't work. The buttons each have a rollover function as well that works just fine. The traces are in there for debugging.

for (var a=0; a<mainButtons.length; a++){
mainButtons[a].buttonMode = true;
mainButtons[a].addEventListener(rolled, hideDbases);
mainButtons[a].addEventListener(clicked, switchView);
}

function switchView(e:Event):void {
    switch (e.target.name) {
        case "count_btn":
            gotoAndPlay(4);
            trace("count");
        break;
        case "order_btn":
            gotoAndPlay(5);
            trace("order");
        break;
        case "admin_btn":
            gotoAndPlay(6);
            trace("admin");
        break;
        case "serve_btn":
            gotoAndPlay(7);
            trace("service");
        break;
        case "video_btn":
            gotoAndPlay(8);
            trace("video");
        break;
    }
}

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

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

发布评论

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

评论(1

旧话新听 2024-10-26 18:39:17

事实证明,我需要为后面的图形指定与主影片剪辑相同的实例名称。我制作的按钮是一个渐变、一个文本框和一个图标。所有三个元素本身都是影片剪辑,然后制作成一个主要影片剪辑。因此,如果父级的实例称为 count_btn,那么我还必须调用渐变背景的实例 count_btn。确实不知道为什么,但问题已经解决了。

Turns out the I needed to give the graphic in the back the same instance name as the main movieclip. The button I made was a gradient, a text box and an icon. All three elements were movieclips themselves and then made into one main movieclip. So if the parent's instance was called count_btn then I had to also call the gradient background's instance count_btn. Don't really know why but the problem is solved.

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