Archive for the ‘Adobe’ Category

Singleton Implementation in flex

January 13, 2008

package scriptFiles
{
   public class Singleton
   {
      private static var INSTANCE : Singleton
      public function Singleton(enforcer:SingletonEnforcer)
      { // construction }
      private static function getInstance(): Singleton
      {
         if(INSTANCE == null)
         {
            INSTANCE = new Singleton(new SingletonEnforcer());
         }
         return INSTANCE;
      }
   }
}
/*
* Constructor
* Dummy private class to enforce Singleton.
*/
class SingletonEnforcer{}