Singleton Pattern : Singleton « Class « Flash / Flex / ActionScript






Singleton Pattern

 
package {

  public class Singleton {
  
    static var instanceCount:uint = 0;

    public function Singleton() {
      instanceCount++;
      if(instanceCount == 1) {
        trace("First Singleton class instance");
      } else {
        trace("Singleton class allows only one instance");
      }
    }

  }
     
}

        








Related examples in the same category

1.Singleton pattern with getInstance