我想将具有实例名称test1的影片剪辑链接到外部网址(例如:http://www.google.com)
我正在使用菜单列表,其主要的movieclip实例名称为“Primary_Menu”。在这个主要的电影剪辑里面有7个菜单(家庭,关于我们等等)。每个菜单都是影片剪辑,并有实例名称。 编写下面的代码是为了将它们链接到各自的帧。但我需要为最后一个菜单(test1)提供外部网址
Home_MC.logo_btn.addEventListener(MouseEvent.CLICK,ShowHome);
Home_MC.Primary_Menu.pmenu_btn1.addEventListener(MouseEvent.CLICK,ShowHome);
Home_MC.Primary_Menu.pmenu_btn2.addEventListener(MouseEvent.CLICK,ShowLocation);
Home_MC.Primary_Menu.pmenu_btn3.addEventListener(MouseEvent.CLICK,ShowMasterplan);
Home_MC.Primary_Menu.pmenu_btn4.addEventListener(MouseEvent.CLICK,ShowDesigner);
Home_MC.Primary_Menu.pmenu_btn5.addEventListener(MouseEvent.CLICK,ShowAmenities);
Home_MC.Primary_Menu.pmenu_btn6.addEventListener(MouseEvent.CLICK,ShowDevelopment);
Home_MC.Primary_Menu.pmenu_btn7.addEventListener(MouseEvent.CLICK,ShowContact);
Home_MC.Primary_Menu.pmenu_btn8.addEventListener(MouseEvent.CLICK,ShowLiving);
Home_MC.Primary_Menu.test1.addEventListener(MouseEvent.CLICK,need to got to url here);
请建议!!
答案 0 :(得分:1)
for( var i:uint = 1;i< 10; i++)
{
Home_MC.Primary_Menu["pmenu_btn"+i].addEventListener(MouseEvent.CLICK, action);
}
function action(e:MouseEvent):void
{
switch(e.target.name){
case "pmenu_btn9":
//do action
navigateToURL(new URLRequest("url link"));
break;
default:
break;
}
}
重命名pmenu_btn9
而不是test1。然后跑。