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