A singleton can be a very useful and essential Object-Oriented device in many instances (no pun intended). Singleton classes only allow one instance of that particular class, and this can be very useful in situations where you want one object to be used throughout your Flash/Flex application instead of many separate ones. I usually use singleton classes for classes that merely act as utility proxies to my applications.

Below is the code to create a very succinct singleton

package
{
	public class Singleton
	{
		private static var _instance:Singleton;
 
		public static function getInstance():Singleton
		{
			if(!_instance) _instance = new Singleton();
 
			return _instance;
		}
	}
}

In the upcoming API i’m planning on releasing, i’ll be using Singletons extensively, and the API will – of course – be open source.