6 Replies - 1431 Views - Last Post: 06 October 2009 - 07:00 AM

#1 1a11ous   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 10-July 09

Error #1010 when trying to run program

Post icon  Posted 05 October 2009 - 12:46 PM

Hello everyone,

I'm fairly new to AS 3.0 and so far I'm enjoying it .
I have been working on my first program but for some reason, I keep on getting the following error:
TypeError: Error #1010: A term is undefined and has no properties.
at Main$iinit()

package 
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	public class Main extends MovieClip
	{
		var startPage:StartPage;
		var hillPage:HillPage;
		var pondPage:PondPage;
		
		 function Main()
		{
			startPage = new StartPage;
			hillPage = new HillPage;
			pondPage = new PondPage;
			addChild(startPage);
			
			startPage.hillButton.addEventListener(MouseEvent.CLICK, onHillButtonclick);
			startPage.pondButton.addEventListener(MouseEvent.CLICK, onPondButtonclick);
			//stage.addEventListener(MouseEvent.CLICK, onclick);
		}
		
		function onHillButtonclick(event:MouseEvent):void
		{
			addChild(hillPage);
			removeChild(startPage);
		}
		
		function onPondButtonclick(event:MouseEvent):void
		{
			addChild(pondPage);
			removeChild(startPage);
		}
		
		
		
		/*public function onclick(event:MouseEvent):void
		{
			trace(event.stageX, event.stageY, event.target);
		}*/
		
			
	}
}


This is my file in case anyone is interested in sorting it out:
http://www.speedysha.../145882628.html

Thanks again

Is This A Good Question/Topic? 0
  • +

Replies To: Error #1010 when trying to run program

#2 Unorthodox   User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 02-October 09

Re: Error #1010 when trying to run program

Posted 05 October 2009 - 09:45 PM

This worked for me:

package {
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	public class Main extends MovieClip {
		var startPage:StartPage = new StartPage();
		var hillPage:HillPage = new HillPage();
		var pondPage:PondPage = new PondPage();
		public function Main() {
			addChild(startPage);
			startPage.hillButton.addEventListener(MouseEvent.CLICK, onHillButtonclick);
			startPage.pondButton.addEventListener(MouseEvent.CLICK, onPondButtonclick);
		}
		 function onHillButtonclick(event:MouseEvent)
		{
			addChild(hillPage);
			removeChild(startPage);
		}
		 function onPondButtonclick(event:MouseEvent)
		{
			addChild(pondPage);
			removeChild(startPage);
		}
	}
}



If the problem persists for you, make sure that every object you are referencing in this AS3 is valid or exists.
Was This Post Helpful? 0
  • +
  • -

#3 1a11ous   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 10-July 09

Re: Error #1010 when trying to run program

Posted 05 October 2009 - 11:50 PM

View PostUnorthodox, on 5 Oct, 2009 - 08:45 PM, said:

This worked for me:

package {
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	public class Main extends MovieClip {
		var startPage:StartPage = new StartPage();
		var hillPage:HillPage = new HillPage();
		var pondPage:PondPage = new PondPage();
		public function Main() {
			addChild(startPage);
			startPage.hillButton.addEventListener(MouseEvent.CLICK, onHillButtonclick);
			startPage.pondButton.addEventListener(MouseEvent.CLICK, onPondButtonclick);
		}
		 function onHillButtonclick(event:MouseEvent)
		{
			addChild(hillPage);
			removeChild(startPage);
		}
		 function onPondButtonclick(event:MouseEvent)
		{
			addChild(pondPage);
			removeChild(startPage);
		}
	}
}



If the problem persists for you, make sure that every object you are referencing in this AS3 is valid or exists.


When I try to debug, the debugger stops at this line:

startPage.hillButton.addEventListener(MouseEvent.CLICK, onHillButtonclick);

If I comment:
startPage.hillButton.addEventListener(MouseEvent.CLICK, onHillButtonclick);
startPage.pondButton.addEventListener(MouseEvent.CLICK, onPondButtonclick);

it works but ofcourse the buttons do not respond to any click.
Was This Post Helpful? 0
  • +
  • -

#4 thehat   User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: Error #1010 when trying to run program

Posted 06 October 2009 - 05:56 AM

Can you display the code for the startPage class? It looks like you're trying to access something inside that class that doesn't exist.
Was This Post Helpful? 0
  • +
  • -

#5 1a11ous   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 10-July 09

Re: Error #1010 when trying to run program

Posted 06 October 2009 - 06:14 AM

StartPage is a Movieclip and startPage is an instance of it.

This is a link to the whole project:

http://www.speedysha.../145882628.html

Thank you,

This post has been edited by 1a11ous: 06 October 2009 - 06:16 AM

Was This Post Helpful? 0
  • +
  • -

#6 thehat   User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: Error #1010 when trying to run program

Posted 06 October 2009 - 06:35 AM

It all becomes clear now I've seen the files!

You don't need to be exporting the two buttons because they're part of the StartPage clip. Go into your library and for each button right click -> properties and uncheck 'Export for ActionScript'.

In your StartPage movie, give the two buttons instance names (hillButton and pondButton).
Was This Post Helpful? 1
  • +
  • -

#7 1a11ous   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 10-July 09

Re: Error #1010 when trying to run program

Posted 06 October 2009 - 07:00 AM

View Postthehat, on 6 Oct, 2009 - 05:35 AM, said:

It all becomes clear now I've seen the files!

You don't need to be exporting the two buttons because they're part of the StartPage clip. Go into your library and for each button right click -> properties and uncheck 'Export for ActionScript'.

In your StartPage movie, give the two buttons instance names (hillButton and pondButton).


Thank You ! Thank You ! :^:

That makes very much sense.

I got it up and running now ! :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1