开发者

AS3 Menu not detecting clicks

开发者 https://www.devze.com 2023-02-14 04:04 出处:网络
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.

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;
  开发者_如何学Go      case "video_btn":
            gotoAndPlay(8);
            trace("video");
        break;
    }
}


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消