Posted By

t3flexdev on 08/01/08


Tagged

model cairngorm


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

THEPWN3R


AppModelLocator MODEL


 / Published in: ActionScript 3
 

PACKAGE### replace -> com.yourdomain.model CLASSFILENAME### replace -> AppModelLocator
  1. package ###PACKAGE### {
  2.  
  3.  
  4. import com.adobe.cairngorm.model.ModelLocator;
  5. import mx.logging.ILogger;
  6.  
  7.  
  8.  
  9. [Bindable]
  10. public class ###CLASSFILENAME### implements ModelLocator {
  11.  
  12. private static var model : AppModelLocator;
  13.  
  14. public function AppLocator() : void {
  15. if ( AppModelLocator.model != null )
  16. throw new Error( "Only one ModelLocator instance should be instantiated" );
  17. }
  18.  
  19. // singleton: always returns the one existing static instance to itself
  20. public static function getInstance() : AppModelLocator {
  21. if ( model == null )
  22. model = new AppModelLocator();
  23. return model;
  24. }
  25. }
  26. }

Report this snippet  

You need to login to post a comment.