Singelton template


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. package app.utils
  2. {
  3. public class Singelton
  4. {
  5.  
  6. private static const m_instance:Singelton = new Singelton(SingeltonLock);
  7.  
  8. public function Singelton(lock:Class)
  9. {
  10. if (lock != SingeltonLock)
  11. {
  12. throw new Error("Singelton can only be accessed through Singelton.getInstance().");
  13. }
  14.  
  15. }
  16.  
  17. private static function get instance():Singelton
  18. {
  19. return m_instance;
  20. }
  21. }
  22. }
  23.  
  24. internal class SingeltonLock
  25. {
  26. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.