Unable to access static var from Document Class in AS3
Posted
by
omidomid
on Stack Overflow
See other posts from Stack Overflow
or by omidomid
Published on 2012-06-17T03:14:01Z
Indexed on
2012/06/17
3:16 UTC
Read the original article
Hit count: 204
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...
© Stack Overflow or respective owner