[AS3] Calling method from a subclass that inherit a superclass

TypeError: Error #1009: Cannot access a property or method of a null o

Page 1 of 1

1 Replies - 4787 Views - Last Post: 05 October 2009 - 02:36 AM

#1 brizick  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 09-March 09

[AS3] Calling method from a subclass that inherit a superclass

Post icon  Posted 02 October 2009 - 11:40 AM

TypeError: Error #1009: Cannot access a property or method of a null object reference.

the main idea is calling a method from subclass that inherit to a superclass..
here is the code

package{
//importing statements

public class Map extends MovieClip{
public var MapID:String;

//constructor
public function loadMap(_mapName:String) {
			var mapClassName:Class=getDefinitionByName(_mapName) as Class;
			var mapMovieClip:MovieClip=new mapClassName as MovieClip;
			stage.addChild(mapMovieClip);
		}
}




package{
//importing statements

public class Town extends Map{
public var MapID:String;

//constructor
public function Town() {
			MapID ="centerTown";
}



package{
//importing statements

public class Program extends MovieClip{

//constructor
public function ElementGodTower() {
			var map:Town= new Town();
			map.loadMap(map.MapID);// these line causes error
		}
}



i've created movieclip class named centerTown
but returning error
TypeError: Error #1009: Cannot access a property or method of a null object reference.

This post has been edited by brizick: 02 October 2009 - 12:25 PM


Is This A Good Question/Topic? 0
  • +

Replies To: [AS3] Calling method from a subclass that inherit a superclass

#2 thehat  Icon User is offline

  • awake ? web();
  • member icon

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

Re: [AS3] Calling method from a subclass that inherit a superclass

Posted 05 October 2009 - 02:36 AM

Can you post your code in a fuller form? I'm having trouble recreating your error.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1