Posted By

kwanhon on 02/02/11


Tagged

actionscript flash Singleton


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

AndrewPotter
j4yc33
junaidrao
shuchii
scottwatkins


AS3 Singleton


 / Published in: ActionScript 3
 

URL: http://life.neophi.com/danielr/2006/10/singleton_pattern_in_as3.html

  1. package {
  2.  
  3. public final class Singleton {
  4.  
  5. private static var instance:Singleton = new Singleton();
  6.  
  7.  
  8. public function Singleton() {
  9.  
  10. if( instance ) throw new Error( "Singleton and can only be accessed through Singleton.getInstance()" );
  11.  
  12. }
  13.  
  14. public static function getInstance():Singleton {
  15.  
  16. return instance;
  17.  
  18. }
  19.  
  20. }
  21.  
  22. }

Report this snippet  

You need to login to post a comment.