Posted By

damarev on 03/04/09


Tagged


Versions (?)

Global.GetInstance()


 / Published in: ActionScript 3
 

Global.GetInstance().SomeFunction();

  1. package
  2. {
  3.  
  4. public class Global
  5. {
  6.  
  7. private static var m_instance:Global = null;
  8.  
  9. public function Global( enforcer:SingletonEnforcer )
  10. {
  11. if (enforcer == null)
  12. {
  13. throw Error("Singleton Enforcer Not Valid. Multiple Instances Not Allowed.");
  14. }
  15. }
  16.  
  17. public static function GetInstance():Global
  18. {
  19. if (m_instance == null)
  20. {
  21. m_instance = new Global( new SingletonEnforcer() );
  22. }
  23. return m_instance;
  24. }
  25.  
  26. }
  27.  
  28. }
  29.  
  30. class SingletonEnforcer{}

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: vip4lyf on March 14, 2009

where can I learn more about Singleton?

You need to login to post a comment.