whats wrong with my singleton class
I have written a singleton class called Stone.as shown below?
package mesh {
public final class Stone{
private static var _instance:Stone;
public function Stone() {
if(_instance){
throw new Error("Singleton... use getInstance()");
}
_instance = this;
}
public static function getInstance():Stone {
if(!_instance){
_instance = new Stone();
}
return _instance;
}
}
}
In the calling class I do this.
var stone:Stone = Stone.getInstance();
However this throws an error;
| 1061: Call to a possibly undefined method getInstance through a reference with static type Class. |
