actionscript-3flash-cs5

AS3 Error #1010


Im taking an AS3 course and on one of the lessons, i get this on the output of my program: TypeError: Error #1010: A term is undefined and has no properties. at Main()

this is my code:

package 
    {

import flash.display.MovieClip;
import flash.events.MouseEvent;

public class Main extends MovieClip
{

    var startPage:StartPage;
    var hillPage:HillPage;
    var lakePage:LakePage;

    public function Main()
    {
        startPage = new StartPage();
        hillPage = new HillPage();
        lakePage = new LakePage();
        addChild(startPage);

        //Add event listeners
        startPage.hillButton.addEventListener(MouseEvent.CLICK, onHillButtonClick);
        startPage.pondButton.addEventListener(MouseEvent.CLICK, onLakeButtonClick);
    }
    //Event handlers
    function onHillButtonClick(event:MouseEvent):void
    {
        addChild(hillPage);
        removeChild(startPage);
    }
    function onLakeButtonClick(event:MouseEvent):void
    {
        addChild(lakePage);
        removeChild(startPage);
    }

  }
}

if you have any help please post it, its driving me crazy.

oh and the buttons on my file itself wont work for some odd reason, as its basically the same exact code as the lesson.

Thank You


Solution

  • Basically that means that you are trying to access an invalid parameter.

    Most likely either or both of startPage.hillButton & startPage.pondButton does not exist. It could also be that you cant perform addEventListener on those items.