The Singleton

[ftf]class MySingleton {

private static var _instance:MySingleton = null;

private function MySingleton() {}

static function getInstance():MySingleton {
if(_instance == null) _instance = new MySingleton();
return _instance;

public function doSomething() {
trace(“This is a singleton method”);


The purpose of a Singleton is to enable access to it from anywhere and ensure you don’t ever have more than one. Another way of looking at it is a _global container of data without using _global.

Get Adobe Flash player