package com.site { public class Singleton2 { //-------------------------------------------------------------------------- // // Class Private Properties // //-------------------------------------------------------------------------- private static var instance:Singleton2; private static var allowInstanciation:Boolean = false; //-------------------------------------------------------------------------- // // Class Public Methods // //-------------------------------------------------------------------------- public static function getInstance():Singleton2 { if (instance == null) { allowInstanciation = true; instance = new Singleton2(); allowInstanciation = false; } return instance; } //-------------------------------------------------------------------------- // // Constructor // //-------------------------------------------------------------------------- public function Singleton2() { if (!allowInstanciation) { throw(new Error("Singleton Error")); } trace("new Singleton2"); } } }