这是代码
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Main extends MovieClip
{
var startPage:StartPage;
var hillPage:HillPage;
var pondPage:PondPage;
public function Main()
{
startPage = new StartPage;
hillPage = new HillPage;
pondPage = new PondPage;
addChild(startPage);
//Add event listeners
startPage.hillButton.addEventListener(MouseEvent.CLICK, onHillButtonClick);
startPage.pondButton.addEventListener(MouseEvent.CLICK, onPondButtonClick);
hillPage.backToStartButton.addEventListener(MouseEvent.CLICK, onBackButtonClick_Hill);
pondPage.backToStartButton.addEventListener(MouseEvent.CLICK, onBackButtonClick_Pond);
}
//Event handlers
function onHillButtonClick(event:MouseEvent):void
{
addChild(hillPage);
removeChild(startPage);
}
function onPondButtonClick(event:MouseEvent):void
{
addChild(pondPage);
removeChild(startPage);
}
function onBackButtonClick_Hill(event:MouseEvent):void
{
addChild(startPage);
removeChild(hillPage);
}
function onBackButtonClick_Pond(event:MouseEvent):void
{
addChild(startPage);
removeChild(pondPage);
}
}
}
所以我可以很好地访问 HillButton 和 PondButton 但 backToStartButton 似乎向我抛出了未定义的术语,我们将不胜感激
如果您想查看代码和 fla 文件,请单击此处