I was wondering if anyone knew how to instantiate an object from a method within an object. The following is an example of what I'm trying to do:
As you can see from the code, the new object is added to the layers list, but when I try to access the created object, none of the properties such as the map array can be access.
Type map Field width:Int=50; Field height:Int=50; Field layers:TList=CreateList(); ' *** CONSTRUCTOR Function Create:map() *** Works fine here End Function Method addLayer(id:Int,layerName:String) **** Following line tries to create new layer object Local layer:mapLayer = New mapLayer.Create(1,layerName,Self.width,Self.height); For Local rep = 1 To 20 layer.map[Rnd(Self.width),Rnd(Self.height)] = 1; Next ListAddLast Self.layers,layer; End Method Method drawMap() **** draw map code End Method End Type Type mapLayer Field id:Int; Field name:String; Field map:Int[50,50]; ' *** CONSTRUCTOR Function Create:mapLayer(layerID:Int,layerName:String,width:Int,height:Int) Local newLayer:mapLayer = New mapLayer 'newLayer.map = New Int[width,height]; newLayer.name = layerName End Function End Type
As you can see from the code, the new object is added to the layers list, but when I try to access the created object, none of the properties such as the map array can be access.