/ Published in: ActionScript 3
This implementation of the singleton pattern provides a way to enforce singleton usage. There are numerous Singleton implementations for AS3 (due to the lack of private constructor) this method, is the cleanest I've seen so far.
Expand |
Embed | Plain Text
package mypackage { public class SingletonExample { public function SingletonExample(enforcer:SingletonEnforcer) { } private static var _instance : SingletonExample; public static function getInstance():SingletonExample { if (_instance == null) _instance = new SingletonExample(new SingletonEnforcer()); return _instance; } } } class SingletonEnforcer {}
You need to login to post a comment.
