Singleton Pattern in AS3

Daniel R.: Singleton Pattern in AS3 --

Problem: No Private or Protected modifiers in AS3.

Nutshell: Best example comes at the end:

private static var inst:Singleton;

public static function getInstance():Singleton {
return inst || (inst = new Singleton());
}

public function Singleton():void {
if( inst ) throw new Error('singleton error');
}

Comments