Pages

AS3 singleton

Best SINGLETON approach in AS3:




package {
public final class Singleton {
private static var instance:Singleton = new Singleton();
public function Singleton() {
if( instance ) throw new Error( "Singleton and can only be accessed through Singleton.getInstance()" );
}
public static function getInstance():Singleton {
return instance;
}
}
}







1 comment :