Singleton Enforcer AS3
Thursday, January 17th, 2008
Just a helpful way to do Singleton’s in AS3 since there is no longer private constructors:
package
{
public class SingletonClass
{
private static var INSTANCE : SingletonClass
public function SingletonClass(enforcer:SingletonEnforcer)
{ // construction }
public static function getInstance(): SingletonClass
{
if(INSTANCE == null)
{
INSTANCE = new SingletonClass(new SingletonEnforcer());
}
return INSTANCE;
}
}
}
class SingletonEnforcer{}