Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package {
- import flash.errors.IllegalOperationError;
- /**
- * Singleton
- *
- * @author Francois
- * @date 6 juin 2011;
- */
- public class Poil{
- private static var _instance:Poil;
- /* *********** *
- * CONSTRUCTOR *
- * *********** */
- /**
- * Creates an instance of <code>Poil</code>.
- */
- public function Poil(enforcer:SingletonEnforcer) {
- if(enforcer == null) {
- throw new IllegalOperationError("A singleton can't be instanciated. Use static accessor 'getInstance()'!");
- }
- initialize();
- }
- /* ***************** *
- * GETTERS / SETTERS *
- * ***************** */
- /**
- * Singleton instance getter.
- */
- public static function getInstance():Poil{
- if(_instance == null)_instance = new Poil(new SingletonEnforcer());
- return _instance;
- }
- /* ****** *
- * PUBLIC *
- * ****** */
- /* ******* *
- * PRIVATE *
- * ******* */
- /**
- * Initialize the class.
- */
- private function initialize():void {
- }
- }
- }
- internal class SingletonEnforcer{}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement