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.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: