我无法让我的导航代码正常工作。我对动作脚本不是很精通,任何人都可以发现我做错了什么?提前致谢
//nav
var home:int = 1;
var about:int = 2;
var projects:int = 3;
var press_id:int = 4;
var contact:int = 5;
home_mc.addEventListener(MouseEvent.CLICK, home);
about_mc.addEventListener(MouseEvent.CLICK, about);
projects_mc.addEventListener(MouseEvent.CLICK,projects);
press_mc.addEventListener(MouseEvent.CLICK, press_id);
contact_mc.addEventListener(MouseEvent.CLICK, contact);
function navbuttonclick(event:MouseEvent, myFrame:Number):void {
gotoAndStop(myFrame);
}
答案 0 :(得分:3)
//define frame indices
const HOME_FRAME:uint = 1;
const ABOUT_US_FRAME:uint = 2;
//set listeners
home_mc.addEventListener(MouseEvent.CLICK, home_mc_clickHandler);
home_mc.addEventListener(MouseEvent.CLICK, about_mc_clickHandler);
//define listeners
function home_mc_clickHandler(event:MouseEvent):void
{
changePage(HOME_FRAME);
}
function about_mc_clickHandler(event:MouseEvent):void
{
changePage(ABOUT_US_FRAME);
}
//change location
function changePage(frameIndex:uint):void
{
gotoAndStop(frameIndex);
}