samedi 28 novembre 2015

AS3 - Error #1009: Cannot access a property or method of a null object reference

I have no idea what is causing the error. I'm sure its very obvious. (See comment in FloorTile).

package src.main{

    import src.tilespack.Tile;

    public class Main{

        public var tile:Tile;

        public function Main{
            var t:Tile = Tile.tiles[0]; //Error caused by this line
        }

Tile:

package src.tilespack{

    public static var tiles:Array = [];

    public static var floorTile:Tile = new FloorTile(0);

    public var bitmapData:BitmapData;

    public function Tile(bitmapData:BitmapData, ID:int)
    {
        this.ID = ID;
        tiles[ID] = this;
        this.bitmapData = bitmapData;
    }

}

FloorTile:

package src.tilespack{
    import src.gfx.Assets;
    import src.tilespack.Tile;

    public class FloorTile extends Tile{ //Error here

        public function FloorTile(ID:int){
            super(Assets.floorTileData, ID);
        }
    }
}

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

Aucun commentaire:

Enregistrer un commentaire