Unable to access static var from Document Class in AS3
- by omidomid
I have a Document class called "CityModule", and an asset with class "City". Below is the coe for each. For some reason, I am unable to access the static variables of the City class from CityModule:
CityModule.as:
package {
public class CityModule extends MovieClip {
public function CityModule() {
var buildings:Array = City.getBuildings();
}
}
}
}
City.as:
package {
import flash.display.MovieClip;
public class City extends MovieClip {
private static var _buildings:Array = [
{className:'City.Generic1', type:'generic'},
{className:'City.Generic2', type:'generic'},
{className:'City.Generic3', type:'generic'}
];
public function City(){
//empty
}
public static function getBuildings():Array{
return _buildings;
}
}
}
Doing this gives me a "Call to a possibly undefined method getBuildings" error. If I instantiate an instance of City, I can see any public/ getters/ setters perfectly fine. But static isn't working...