Posted By

elvman on 08/17/11


Tagged


Versions (?)

Singleton


 / Published in: ActionScript 3
 

  1. public function Singleton(caller:Function = null):void
  2. {
  3. if ( caller == hidden )
  4. {
  5. _instance = this;
  6. }
  7. else
  8. {
  9. throw new Error( "Please use the instance property to access." );
  10. }
  11. }
  12.  
  13. public static function get instance():Singleton
  14. {
  15. if (!_instance)
  16. {
  17. new Singleton(hidden);
  18. }
  19. return _instance;
  20. }
  21.  
  22. private static function hidden():void { }

Report this snippet  

You need to login to post a comment.