我正在尝试创建一个动态Flash导航菜单,该菜单将禁用您正在离开按钮处于“点击”状态的页面按钮,然后在您调用新页面并取消激活新按钮后激活它
我知道这可以通过电影剪辑和一些旧学校gotoAndPlay / Stop轻微完成,但我想在动作中做到这一点,所以它很好,干净,可扩展到其他项目。
我在
的zip文件中发布了我的尝试http://www.webstudioproductions.com/navtry.zip
请在任何帮助下重播
//已编辑添加
我从php include函数调用此swf。当我在当前状态下尝试使用swf时,所有按钮,但主页已停用,主页应该关闭,让用户翻转并激活。
stop();
//get page string
var pageURL:String=ExternalInterface.call('window.location.href.toString');
//set up website pages
var homeURL:String=('http://www.webstudioproductions.com/index.html');
var servicesURL:String=('http://www.webstudioproductions.com/services.html');
var portfolioURL:String=('http://www.webstudioproductions.com/portfolio.html');
var associatesURL:String=('http://www.webstudioproductions.com/associates.html');
var contactusURL:String=('http://www.webstudioproductions.com/contactus.html');
// show rollover state of pageURL
function pageLoad():void {
if(pageURL==homeURL) {
nav.nav_home.gotoAndPlay("hit");
}else if(pageURL==servicesURL){
nav.nav_service.gotoAndPlay("hit");
}else if(pageURL==portfolioURL){
nav.nav_portfolio.gotoAndPlay("hit");
}else if(pageURL==associatesURL){
nav.nav_associates.gotoAndPlay("hit");
}else if(pageURL==contactusURL){
nav.nav_contactus.gotoAndPlay("hit");
}else{
gotoAndStop(1);
}
}
pageLoad();
/* main nav */
nav.nav_home.buttonMode = true;
nav.nav_home.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
nav.nav_home.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
nav.nav_home.addEventListener(MouseEvent.CLICK, nav_homeClick);
nav.nav_service.buttonMode = true;
nav.nav_service.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
nav.nav_service.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
nav.nav_service.addEventListener(MouseEvent.CLICK, nav_serviceClick);
nav.nav_portfolio.buttonMode = true;
nav.nav_portfolio.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
nav.nav_portfolio.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
nav.nav_portfolio.addEventListener(MouseEvent.CLICK, nav_portfolioClick);
nav.nav_associates.buttonMode = true;
nav.nav_associates.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
nav.nav_associates.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
nav.nav_associates.addEventListener(MouseEvent.CLICK, nav_associatesClick);
nav.nav_contactus.buttonMode = true;
nav.nav_contactus.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
nav.nav_contactus.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
nav.nav_contactus.addEventListener(MouseEvent.CLICK, nav_contactusClick);
function onButtonOver(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("over");
}
function onButtonOut(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("out");
}
/* main nav */
function nav_homeClick(e:MouseEvent):void
{
var nav_homeURL:URLRequest = new URLRequest ("http://www.webstudioproductions.com/index.html");
navigateToURL(nav_homeURL, "_parent");
}
function nav_serviceClick(e:MouseEvent):void
{
var nav_serviceURL:URLRequest = new URLRequest ("http://www.webstudioproductions.com/services.html");
navigateToURL(nav_serviceURL, "_parent");
}
function nav_portfolioClick(e:MouseEvent):void
{
var nav_portfolioURL:URLRequest = new URLRequest ("http://www.webstudioproductions.com/portfolio.html");
navigateToURL(nav_portfolioURL, "_parent");
}
function nav_associatesClick(e:MouseEvent):void
{
var nav_associatesURL:URLRequest = new URLRequest ("http://www.webstudioproductions.com/associates.html");
navigateToURL(nav_associatesURL, "_parent");
}
function nav_contactusClick(e:MouseEvent):void
{
var nav_contactusURL:URLRequest = new URLRequest ("http://www.webstudioproductions.com/contactus.html");
navigateToURL(nav_contactusURL, "_parent");
}
答案 0 :(得分:0)
MovieClip是一个动态类,因此您可以为其提供额外的属性。解决此问题的一种方法是为每个菜单项提供一个isSelected布尔值。然后在父类中,将所有项存储在数组中并控制所选值。
我使用的简单系统就是这样的
给每个菜单一个isSelected布尔值
如果isSelected == true,则阻止取消选择动画
将所有菜单按钮存储在一个数组中
为每个菜单项创建一个setOn和setOff函数
按下菜单时,循环显示所有按钮并更新所选状态
function onButtonOut(e:MouseEvent):void
{
if(!isSelected) e.currentTarget.gotoAndPlay("out");
}