AS3 菜单未检测到点击
我有一些按钮可以在时间轴上导航。我试图制作一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,我需要为后面的图形指定与主影片剪辑相同的实例名称。我制作的按钮是一个渐变、一个文本框和一个图标。所有三个元素本身都是影片剪辑,然后制作成一个主要影片剪辑。因此,如果父级的实例称为 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.