In object-oriented programming , a singleton class is a class that can have only one object (an instance of the class) at a time.
It's good when you only want one object across the whole of your application
It is usually used in flex to add Global State to a project.In other words,
It allows you to do things like set and have access to global variables from anywhere in your application.
To access a variable from the Singleton class we use the following.
private var model:Singleton = Singleton.getInstance();
Full code goes here!
<pre>public class Singleton
private static var instance:Singleton = new Singleton();
public var flexData:String = "FirstApp";
public var userScore:int = 0;
public function Singleton()
throw new Error ("new instance cannot be created");
public static function getInstance():Singleton