0
votes

I have a problem with accessing properties from different packages. I can't access any properties of the Assets class from the FloorTile Class. How do I get floorTileData from Assets?

Assets:

package src.gfx{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Point;

    public class Assets{
        public var floorTileData:BitmapData = new BitmapData(0, 0); 

        //Other Code

    }

}

FloorTile:

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

    public class FloorTile extends Tile{

        public function FloorTile(ID:int){
            super(Assets.floorTileData, ID); //Error in this line
        }
    }
}

The error is due to this line

super(Assets.floorTileData, ID);

I get the Error - 1119: Access of possibly undefined property floorTileData through a reference with static type Class.

1

1 Answers

0
votes

The problem happens because you try to acces the variable floorTimeData as a static variable, but it's an instance variable. So, you have to think what it should be and make neccessary changes for your approach.

1) It should be a static variable (please, pay attention to the keyword static):

package src.gfx
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.geom.Rectangle;
    import flash.geom.Point;

    public class Assets
    {
        public static var floorTileData:BitmapData = new BitmapData(0, 0); 
    }
}

2) It should be an instance variable:

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

    public class FloorTile extends Tile
    {
        public function FloorTile(ID:int)
        {
            var tempAssets:Assets = new Assets();
            super(tempAssets.floorTileData, ID); //Error in this line
        }
    }
}