here’s the code
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);
}
}
}
so i can access HillButton and PondButton just fine but backToStartButton appears to be throwing the undefined term at me any and all help would be appreciated
if you want to see the code and fla file click here
You are referencing to hillPage.backToStartButton and pondPage.backToStartButton but browsing those items in your library, it seems you did not give those buttons an instance name, resulting in the undefined error. Also you created AS linkages which is not necessary in this case as these items are not dynamically created nor implement a custom class. It seems like you are confusing things: the AS linkage is not used for referencing to instances through code.
So to have things work in your particular situation: remove the as linkage names in your library, edit the hillPage and pondPage by clicking the back button inside those items and setting their instance name which your code will then use to reference the button.