Main.as
InteractiveStorybook.fla
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);
}
// here are the 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);
}
}
}
No comments:
Post a Comment