Posted By

zwigby on 07/16/10


Tagged

model


Versions (?)

Flex Model Singleton


 / Published in: ActionScript
 

  1. package
  2. {
  3. [Bindable]
  4. public class MainModel
  5. {
  6. private static var _instance:MainModel = new MainModel(ModelEnforcer);
  7.  
  8. public static function getInstance():MainModel
  9. {
  10. return _instance;
  11. }
  12.  
  13. public function MainModel(enforcer:Class)
  14. {
  15. if(enforcer != ModelEnforcer) {
  16. throw new Error("Use MainModel.getInstance to access model");
  17. }
  18. }
  19.  
  20. }
  21. }
  22.  
  23. class ModelEnforcer {}

Report this snippet  

You need to login to post a comment.