A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: [RESOLVED] Error 1010 - Interactive Storybook

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    12

    resolved [RESOLVED] Error 1010 - Interactive Storybook

    Hi guys, I'm receiving the following error while coding my storybook.

    TypeError: Error #1010: A term is undefined and has no properties.
    at Main()[M:\Documents\InteractiveStorybook\Main.as:22]
    I am working from "Foundation Games Design with Flash". My code is below.

    Code:
    	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.startButton.addEventListener(MouseEvent.CLICK,onStartButtonClickHill);
    			pondPage.startButton.addEventListener(MouseEvent.CLICK,onStartButtonClickPond);
    		}
    		//Event handlers
    		function onHillButtonClick(event:MouseEvent):void
    		{
    			addChild(hillPage);
    			removeChild(startPage);
    		}
    		function onPondButtonClick(event:MouseEvent):void
    		{
    			addChild(pondPage);
    			removeChild(startPage);
    		}
    		function onStartButtonClickHill(event:MouseEvent):void
    		{
    			addChild(startPage);
    			removeChild(hillPage);
    		}
    		function onStartButtonClickPond(event:MouseEvent):void
    		{
    			addChild(startPage);
    			removeChild(pondPage);
    		}
    In particular, it is these 2 lines of code that are causing the problems (after a few rounds of debugging.
    Code:
    hillPage.startButton.addEventListener(MouseEvent.CLICK,onStartButtonClickHill);
    pondPage.startButton.addEventListener(MouseEvent.CLICK,onStartButtonClickPond);

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    Russia: Western Siberia
    Posts
    268
    The debugger shows you the exact line that causes the problem, it's 22. Find line 22 in your code and trace everything that might cause the problem there

  3. #3
    Junior Member
    Join Date
    Mar 2011
    Posts
    12
    Caseyryan, I've traced it down to the 2 lines. Those 2 lines of code were found to be the bad ones after a set of debugging.

    Code:
    hillPage.startButton.addEventListener(MouseEvent.CLICK,onStartButtonClickHill);
    pondPage.startButton.addEventListener(MouseEvent.CLICK,onStartButtonClickPond);
    How do I get them to work?

  4. #4
    Senior Member
    Join Date
    May 2010
    Location
    Russia: Western Siberia
    Posts
    268
    All I can say by this code, is that whether hillPage, or pondPage or startButton is null.

    Upload your project here, and I'll tell you exactly what the problem is

  5. #5
    Junior Member
    Join Date
    Mar 2011
    Posts
    12
    Interestingly, the buttons on the startPage are working correctly, it's the buttons from the hillPage/pondPage to the startPage that are not working.

  6. #6
    Senior Member
    Join Date
    May 2010
    Location
    Russia: Western Siberia
    Posts
    268
    I'm sure it's a very simple problem, but you'll have to find it yourself, since you didn't upload your file here

  7. #7
    Junior Member
    Join Date
    Mar 2011
    Posts
    12
    FLA file
    ActionScript file

    The AS file wasn't accepted by the forums, and the FLA file was too big... plus it also seemed the SWF wouldn't work...

  8. #8
    Senior Member
    Join Date
    May 2010
    Location
    Russia: Western Siberia
    Posts
    268
    hehe, that's a very obvious mistake that all novices do.
    If you open your PondPage or HillPage symbol, and select the button, you'll see that it has no instance name.

    Add and instance name of "startButton" to each of them and it will all work just fine

  9. #9
    Junior Member
    Join Date
    Mar 2011
    Posts
    12
    Where's the "Thanks" button when you need it? LOL. Thanks though, didn't realise I'd made such a novice mistake, called both instances startButton and it's working fine. I have also edited the ActionScript code slightly so as to follow the conventions in the book, and all is fine still.

    You sir, are a genius.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center